]> asedeno.scripts.mit.edu Git - linux.git/blob - drivers/net/ethernet/sfc/efx_common.h
e03404d1dc0ad1c3054b090dd9ef8e2cc9ec4612
[linux.git] / drivers / net / ethernet / sfc / efx_common.h
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /****************************************************************************
3  * Driver for Solarflare network controllers and boards
4  * Copyright 2018 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_COMMON_H
12 #define EFX_COMMON_H
13
14 int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask,
15                 unsigned int mem_map_size);
16 void efx_fini_io(struct efx_nic *efx, int bar);
17 int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev,
18                     struct net_device *net_dev);
19 void efx_fini_struct(struct efx_nic *efx);
20
21 void efx_start_all(struct efx_nic *efx);
22 void efx_stop_all(struct efx_nic *efx);
23
24 int efx_create_reset_workqueue(void);
25 void efx_queue_reset_work(struct efx_nic *efx);
26 void efx_flush_reset_workqueue(struct efx_nic *efx);
27 void efx_destroy_reset_workqueue(void);
28
29 void efx_start_monitor(struct efx_nic *efx);
30
31 int __efx_reconfigure_port(struct efx_nic *efx);
32 int efx_reconfigure_port(struct efx_nic *efx);
33
34 #define EFX_ASSERT_RESET_SERIALISED(efx)                \
35         do {                                            \
36                 if ((efx->state == STATE_READY) ||      \
37                     (efx->state == STATE_RECOVERY) ||   \
38                     (efx->state == STATE_DISABLED))     \
39                         ASSERT_RTNL();                  \
40         } while (0)
41
42 int efx_try_recovery(struct efx_nic *efx);
43 void efx_reset_down(struct efx_nic *efx, enum reset_type method);
44 int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok);
45 int efx_reset(struct efx_nic *efx, enum reset_type method);
46 void efx_schedule_reset(struct efx_nic *efx, enum reset_type type);
47
48 static inline int efx_check_disabled(struct efx_nic *efx)
49 {
50         if (efx->state == STATE_DISABLED || efx->state == STATE_RECOVERY) {
51                 netif_err(efx, drv, efx->net_dev,
52                           "device is disabled due to earlier errors\n");
53                 return -EIO;
54         }
55         return 0;
56 }
57
58 #ifdef CONFIG_SFC_MCDI_LOGGING
59 void efx_init_mcdi_logging(struct efx_nic *efx);
60 void efx_fini_mcdi_logging(struct efx_nic *efx);
61 #else
62 static inline void efx_init_mcdi_logging(struct efx_nic *efx) {}
63 static inline void efx_fini_mcdi_logging(struct efx_nic *efx) {}
64 #endif
65
66 void efx_mac_reconfigure(struct efx_nic *efx);
67 void efx_link_status_changed(struct efx_nic *efx);
68
69 #endif