blob: 46dd43bbbfd94b4e7d9bdf63cf432c7102515f59 [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
Ben Hutchings5c16a962009-11-23 16:05:28 +000014#include <linux/i2c-algo-bit.h>
Ben Hutchings8ceee662008-04-27 12:55:59 +010015#include "net_driver.h"
Ben Hutchings177dfcd2008-12-12 21:50:08 -080016#include "efx.h"
Ben Hutchings8ceee662008-04-27 12:55:59 +010017
18/*
19 * Falcon hardware control
20 */
21
22enum falcon_revision {
23 FALCON_REV_A0 = 0,
24 FALCON_REV_A1 = 1,
25 FALCON_REV_B0 = 2,
26};
27
Ben Hutchings55668612008-05-16 21:16:10 +010028static inline int falcon_rev(struct efx_nic *efx)
29{
30 return efx->pci_dev->revision;
31}
Ben Hutchings8ceee662008-04-27 12:55:59 +010032
Ben Hutchings5c16a962009-11-23 16:05:28 +000033/**
34 * struct falcon_nic_data - Falcon NIC state
35 * @pci_dev2: The secondary PCI device if present
36 * @i2c_data: Operations and state for I2C bit-bashing algorithm
37 */
38struct falcon_nic_data {
39 struct pci_dev *pci_dev2;
40 struct i2c_algo_bit_data i2c_data;
41};
42
Ben Hutchings278c0622009-11-23 16:05:12 +000043static inline struct falcon_board *falcon_board(struct efx_nic *efx)
44{
45 return &efx->board_info;
46}
47
Ben Hutchings8ceee662008-04-27 12:55:59 +010048extern struct efx_nic_type falcon_a_nic_type;
49extern struct efx_nic_type falcon_b_nic_type;
50
51/**************************************************************************
52 *
53 * Externs
54 *
55 **************************************************************************
56 */
57
Ben Hutchings5087b542009-10-23 08:29:51 +000058extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info);
59
Ben Hutchings8ceee662008-04-27 12:55:59 +010060/* TX data path */
61extern int falcon_probe_tx(struct efx_tx_queue *tx_queue);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010062extern void falcon_init_tx(struct efx_tx_queue *tx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +010063extern void falcon_fini_tx(struct efx_tx_queue *tx_queue);
64extern void falcon_remove_tx(struct efx_tx_queue *tx_queue);
65extern void falcon_push_buffers(struct efx_tx_queue *tx_queue);
66
67/* RX data path */
68extern int falcon_probe_rx(struct efx_rx_queue *rx_queue);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010069extern void falcon_init_rx(struct efx_rx_queue *rx_queue);
Ben Hutchings8ceee662008-04-27 12:55:59 +010070extern void falcon_fini_rx(struct efx_rx_queue *rx_queue);
71extern void falcon_remove_rx(struct efx_rx_queue *rx_queue);
72extern void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue);
73
74/* Event data path */
75extern int falcon_probe_eventq(struct efx_channel *channel);
Ben Hutchingsbc3c90a2008-09-01 12:48:46 +010076extern void falcon_init_eventq(struct efx_channel *channel);
Ben Hutchings8ceee662008-04-27 12:55:59 +010077extern void falcon_fini_eventq(struct efx_channel *channel);
78extern void falcon_remove_eventq(struct efx_channel *channel);
Ben Hutchings42cbe2d2008-09-01 12:48:08 +010079extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota);
Ben Hutchings8ceee662008-04-27 12:55:59 +010080extern void falcon_eventq_read_ack(struct efx_channel *channel);
81
82/* Ports */
83extern int falcon_probe_port(struct efx_nic *efx);
84extern void falcon_remove_port(struct efx_nic *efx);
85
86/* MAC/PHY */
Ben Hutchings177dfcd2008-12-12 21:50:08 -080087extern int falcon_switch_mac(struct efx_nic *efx);
Ben Hutchingsdc8cfa52008-09-01 12:46:50 +010088extern bool falcon_xaui_link_ok(struct efx_nic *efx);
Ben Hutchings8ceee662008-04-27 12:55:59 +010089extern int falcon_dma_stats(struct efx_nic *efx,
90 unsigned int done_offset);
91extern void falcon_drain_tx_fifo(struct efx_nic *efx);
92extern void falcon_deconfigure_mac_wrapper(struct efx_nic *efx);
93extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx);
94
95/* Interrupts and test events */
96extern int falcon_init_interrupt(struct efx_nic *efx);
97extern void falcon_enable_interrupts(struct efx_nic *efx);
98extern void falcon_generate_test_event(struct efx_channel *channel,
99 unsigned int magic);
Ben Hutchings177dfcd2008-12-12 21:50:08 -0800100extern void falcon_sim_phy_event(struct efx_nic *efx);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100101extern void falcon_generate_interrupt(struct efx_nic *efx);
102extern void falcon_set_int_moderation(struct efx_channel *channel);
103extern void falcon_disable_interrupts(struct efx_nic *efx);
104extern void falcon_fini_interrupt(struct efx_nic *efx);
105
Ben Hutchings6fb70fd2009-03-20 13:30:37 +0000106#define FALCON_IRQ_MOD_RESOLUTION 5
107
Ben Hutchings8ceee662008-04-27 12:55:59 +0100108/* Global Resources */
109extern int falcon_probe_nic(struct efx_nic *efx);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100110extern int falcon_init_nic(struct efx_nic *efx);
Ben Hutchings6bc5d3a2008-09-01 12:49:37 +0100111extern int falcon_flush_queues(struct efx_nic *efx);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100112extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method);
Ben Hutchings8ceee662008-04-27 12:55:59 +0100113extern void falcon_remove_nic(struct efx_nic *efx);
114extern void falcon_update_nic_stats(struct efx_nic *efx);
115extern void falcon_set_multicast_hash(struct efx_nic *efx);
116extern int falcon_reset_xaui(struct efx_nic *efx);
117
Ben Hutchings8c8661e2008-09-01 12:49:02 +0100118/* Tests */
119struct falcon_nvconfig;
120extern int falcon_read_nvram(struct efx_nic *efx,
121 struct falcon_nvconfig *nvconfig);
122extern int falcon_test_registers(struct efx_nic *efx);
123
Ben Hutchings8ceee662008-04-27 12:55:59 +0100124/**************************************************************************
125 *
126 * Falcon MAC stats
127 *
128 **************************************************************************
129 */
130
131#define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset)
132#define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH)
133
134/* Retrieve statistic from statistics block */
135#define FALCON_STAT(efx, falcon_stat, efx_stat) do { \
136 if (FALCON_STAT_WIDTH(falcon_stat) == 16) \
137 (efx)->mac_stats.efx_stat += le16_to_cpu( \
138 *((__force __le16 *) \
139 (efx->stats_buffer.addr + \
140 FALCON_STAT_OFFSET(falcon_stat)))); \
141 else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \
142 (efx)->mac_stats.efx_stat += le32_to_cpu( \
143 *((__force __le32 *) \
144 (efx->stats_buffer.addr + \
145 FALCON_STAT_OFFSET(falcon_stat)))); \
146 else \
147 (efx)->mac_stats.efx_stat += le64_to_cpu( \
148 *((__force __le64 *) \
149 (efx->stats_buffer.addr + \
150 FALCON_STAT_OFFSET(falcon_stat)))); \
151 } while (0)
152
153#define FALCON_MAC_STATS_SIZE 0x100
154
155#define MAC_DATA_LBN 0
156#define MAC_DATA_WIDTH 32
157
158extern void falcon_generate_event(struct efx_channel *channel,
159 efx_qword_t *event);
160
161#endif /* EFX_FALCON_H */