Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 1 | /**************************************************************************** |
| 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 Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 15 | #include "efx.h" |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * Falcon hardware control |
| 19 | */ |
| 20 | |
| 21 | enum falcon_revision { |
| 22 | FALCON_REV_A0 = 0, |
| 23 | FALCON_REV_A1 = 1, |
| 24 | FALCON_REV_B0 = 2, |
| 25 | }; |
| 26 | |
Ben Hutchings | 5566861 | 2008-05-16 21:16:10 +0100 | [diff] [blame] | 27 | static inline int falcon_rev(struct efx_nic *efx) |
| 28 | { |
| 29 | return efx->pci_dev->revision; |
| 30 | } |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 31 | |
Ben Hutchings | 278c062 | 2009-11-23 16:05:12 +0000 | [diff] [blame^] | 32 | static inline struct falcon_board *falcon_board(struct efx_nic *efx) |
| 33 | { |
| 34 | return &efx->board_info; |
| 35 | } |
| 36 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 37 | extern struct efx_nic_type falcon_a_nic_type; |
| 38 | extern struct efx_nic_type falcon_b_nic_type; |
| 39 | |
| 40 | /************************************************************************** |
| 41 | * |
| 42 | * Externs |
| 43 | * |
| 44 | ************************************************************************** |
| 45 | */ |
| 46 | |
Ben Hutchings | 5087b54 | 2009-10-23 08:29:51 +0000 | [diff] [blame] | 47 | extern void falcon_probe_board(struct efx_nic *efx, u16 revision_info); |
| 48 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 49 | /* TX data path */ |
| 50 | extern int falcon_probe_tx(struct efx_tx_queue *tx_queue); |
Ben Hutchings | bc3c90a | 2008-09-01 12:48:46 +0100 | [diff] [blame] | 51 | extern void falcon_init_tx(struct efx_tx_queue *tx_queue); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 52 | extern void falcon_fini_tx(struct efx_tx_queue *tx_queue); |
| 53 | extern void falcon_remove_tx(struct efx_tx_queue *tx_queue); |
| 54 | extern void falcon_push_buffers(struct efx_tx_queue *tx_queue); |
| 55 | |
| 56 | /* RX data path */ |
| 57 | extern int falcon_probe_rx(struct efx_rx_queue *rx_queue); |
Ben Hutchings | bc3c90a | 2008-09-01 12:48:46 +0100 | [diff] [blame] | 58 | extern void falcon_init_rx(struct efx_rx_queue *rx_queue); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 59 | extern void falcon_fini_rx(struct efx_rx_queue *rx_queue); |
| 60 | extern void falcon_remove_rx(struct efx_rx_queue *rx_queue); |
| 61 | extern void falcon_notify_rx_desc(struct efx_rx_queue *rx_queue); |
| 62 | |
| 63 | /* Event data path */ |
| 64 | extern int falcon_probe_eventq(struct efx_channel *channel); |
Ben Hutchings | bc3c90a | 2008-09-01 12:48:46 +0100 | [diff] [blame] | 65 | extern void falcon_init_eventq(struct efx_channel *channel); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 66 | extern void falcon_fini_eventq(struct efx_channel *channel); |
| 67 | extern void falcon_remove_eventq(struct efx_channel *channel); |
Ben Hutchings | 42cbe2d | 2008-09-01 12:48:08 +0100 | [diff] [blame] | 68 | extern int falcon_process_eventq(struct efx_channel *channel, int rx_quota); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 69 | extern void falcon_eventq_read_ack(struct efx_channel *channel); |
| 70 | |
| 71 | /* Ports */ |
| 72 | extern int falcon_probe_port(struct efx_nic *efx); |
| 73 | extern void falcon_remove_port(struct efx_nic *efx); |
| 74 | |
| 75 | /* MAC/PHY */ |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 76 | extern int falcon_switch_mac(struct efx_nic *efx); |
Ben Hutchings | dc8cfa5 | 2008-09-01 12:46:50 +0100 | [diff] [blame] | 77 | extern bool falcon_xaui_link_ok(struct efx_nic *efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 78 | extern int falcon_dma_stats(struct efx_nic *efx, |
| 79 | unsigned int done_offset); |
| 80 | extern void falcon_drain_tx_fifo(struct efx_nic *efx); |
| 81 | extern void falcon_deconfigure_mac_wrapper(struct efx_nic *efx); |
| 82 | extern void falcon_reconfigure_mac_wrapper(struct efx_nic *efx); |
| 83 | |
| 84 | /* Interrupts and test events */ |
| 85 | extern int falcon_init_interrupt(struct efx_nic *efx); |
| 86 | extern void falcon_enable_interrupts(struct efx_nic *efx); |
| 87 | extern void falcon_generate_test_event(struct efx_channel *channel, |
| 88 | unsigned int magic); |
Ben Hutchings | 177dfcd | 2008-12-12 21:50:08 -0800 | [diff] [blame] | 89 | extern void falcon_sim_phy_event(struct efx_nic *efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 90 | extern void falcon_generate_interrupt(struct efx_nic *efx); |
| 91 | extern void falcon_set_int_moderation(struct efx_channel *channel); |
| 92 | extern void falcon_disable_interrupts(struct efx_nic *efx); |
| 93 | extern void falcon_fini_interrupt(struct efx_nic *efx); |
| 94 | |
Ben Hutchings | 6fb70fd | 2009-03-20 13:30:37 +0000 | [diff] [blame] | 95 | #define FALCON_IRQ_MOD_RESOLUTION 5 |
| 96 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 97 | /* Global Resources */ |
| 98 | extern int falcon_probe_nic(struct efx_nic *efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 99 | extern int falcon_init_nic(struct efx_nic *efx); |
Ben Hutchings | 6bc5d3a | 2008-09-01 12:49:37 +0100 | [diff] [blame] | 100 | extern int falcon_flush_queues(struct efx_nic *efx); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 101 | extern int falcon_reset_hw(struct efx_nic *efx, enum reset_type method); |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 102 | extern void falcon_remove_nic(struct efx_nic *efx); |
| 103 | extern void falcon_update_nic_stats(struct efx_nic *efx); |
| 104 | extern void falcon_set_multicast_hash(struct efx_nic *efx); |
| 105 | extern int falcon_reset_xaui(struct efx_nic *efx); |
| 106 | |
Ben Hutchings | 8c8661e | 2008-09-01 12:49:02 +0100 | [diff] [blame] | 107 | /* Tests */ |
| 108 | struct falcon_nvconfig; |
| 109 | extern int falcon_read_nvram(struct efx_nic *efx, |
| 110 | struct falcon_nvconfig *nvconfig); |
| 111 | extern int falcon_test_registers(struct efx_nic *efx); |
| 112 | |
Ben Hutchings | 8ceee66 | 2008-04-27 12:55:59 +0100 | [diff] [blame] | 113 | /************************************************************************** |
| 114 | * |
| 115 | * Falcon MAC stats |
| 116 | * |
| 117 | ************************************************************************** |
| 118 | */ |
| 119 | |
| 120 | #define FALCON_STAT_OFFSET(falcon_stat) EFX_VAL(falcon_stat, offset) |
| 121 | #define FALCON_STAT_WIDTH(falcon_stat) EFX_VAL(falcon_stat, WIDTH) |
| 122 | |
| 123 | /* Retrieve statistic from statistics block */ |
| 124 | #define FALCON_STAT(efx, falcon_stat, efx_stat) do { \ |
| 125 | if (FALCON_STAT_WIDTH(falcon_stat) == 16) \ |
| 126 | (efx)->mac_stats.efx_stat += le16_to_cpu( \ |
| 127 | *((__force __le16 *) \ |
| 128 | (efx->stats_buffer.addr + \ |
| 129 | FALCON_STAT_OFFSET(falcon_stat)))); \ |
| 130 | else if (FALCON_STAT_WIDTH(falcon_stat) == 32) \ |
| 131 | (efx)->mac_stats.efx_stat += le32_to_cpu( \ |
| 132 | *((__force __le32 *) \ |
| 133 | (efx->stats_buffer.addr + \ |
| 134 | FALCON_STAT_OFFSET(falcon_stat)))); \ |
| 135 | else \ |
| 136 | (efx)->mac_stats.efx_stat += le64_to_cpu( \ |
| 137 | *((__force __le64 *) \ |
| 138 | (efx->stats_buffer.addr + \ |
| 139 | FALCON_STAT_OFFSET(falcon_stat)))); \ |
| 140 | } while (0) |
| 141 | |
| 142 | #define FALCON_MAC_STATS_SIZE 0x100 |
| 143 | |
| 144 | #define MAC_DATA_LBN 0 |
| 145 | #define MAC_DATA_WIDTH 32 |
| 146 | |
| 147 | extern void falcon_generate_event(struct efx_channel *channel, |
| 148 | efx_qword_t *event); |
| 149 | |
| 150 | #endif /* EFX_FALCON_H */ |