162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/**************************************************************************** 362306a36Sopenharmony_ci * Driver for Solarflare network controllers and boards 462306a36Sopenharmony_ci * Copyright 2018 Solarflare Communications Inc. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it 762306a36Sopenharmony_ci * under the terms of the GNU General Public License version 2 as published 862306a36Sopenharmony_ci * by the Free Software Foundation, incorporated herein by reference. 962306a36Sopenharmony_ci */ 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#ifndef EFX_COMMON_H 1262306a36Sopenharmony_ci#define EFX_COMMON_H 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ciint efx_siena_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask, 1562306a36Sopenharmony_ci unsigned int mem_map_size); 1662306a36Sopenharmony_civoid efx_siena_fini_io(struct efx_nic *efx); 1762306a36Sopenharmony_ciint efx_siena_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev, 1862306a36Sopenharmony_ci struct net_device *net_dev); 1962306a36Sopenharmony_civoid efx_siena_fini_struct(struct efx_nic *efx); 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci#define EFX_MAX_DMAQ_SIZE 4096UL 2262306a36Sopenharmony_ci#define EFX_DEFAULT_DMAQ_SIZE 1024UL 2362306a36Sopenharmony_ci#define EFX_MIN_DMAQ_SIZE 512UL 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#define EFX_MAX_EVQ_SIZE 16384UL 2662306a36Sopenharmony_ci#define EFX_MIN_EVQ_SIZE 512UL 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_civoid efx_siena_link_clear_advertising(struct efx_nic *efx); 2962306a36Sopenharmony_civoid efx_siena_link_set_wanted_fc(struct efx_nic *efx, u8 wanted_fc); 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_civoid efx_siena_start_all(struct efx_nic *efx); 3262306a36Sopenharmony_civoid efx_siena_stop_all(struct efx_nic *efx); 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_civoid efx_siena_net_stats(struct net_device *net_dev, 3562306a36Sopenharmony_ci struct rtnl_link_stats64 *stats); 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ciint efx_siena_create_reset_workqueue(void); 3862306a36Sopenharmony_civoid efx_siena_queue_reset_work(struct efx_nic *efx); 3962306a36Sopenharmony_civoid efx_siena_flush_reset_workqueue(struct efx_nic *efx); 4062306a36Sopenharmony_civoid efx_siena_destroy_reset_workqueue(void); 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_civoid efx_siena_start_monitor(struct efx_nic *efx); 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciint __efx_siena_reconfigure_port(struct efx_nic *efx); 4562306a36Sopenharmony_ciint efx_siena_reconfigure_port(struct efx_nic *efx); 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_ci#define EFX_ASSERT_RESET_SERIALISED(efx) \ 4862306a36Sopenharmony_ci do { \ 4962306a36Sopenharmony_ci if ((efx->state == STATE_READY) || \ 5062306a36Sopenharmony_ci (efx->state == STATE_RECOVERY) || \ 5162306a36Sopenharmony_ci (efx->state == STATE_DISABLED)) \ 5262306a36Sopenharmony_ci ASSERT_RTNL(); \ 5362306a36Sopenharmony_ci } while (0) 5462306a36Sopenharmony_ci 5562306a36Sopenharmony_ciint efx_siena_try_recovery(struct efx_nic *efx); 5662306a36Sopenharmony_civoid efx_siena_reset_down(struct efx_nic *efx, enum reset_type method); 5762306a36Sopenharmony_civoid efx_siena_watchdog(struct net_device *net_dev, unsigned int txqueue); 5862306a36Sopenharmony_ciint efx_siena_reset_up(struct efx_nic *efx, enum reset_type method, bool ok); 5962306a36Sopenharmony_ciint efx_siena_reset(struct efx_nic *efx, enum reset_type method); 6062306a36Sopenharmony_civoid efx_siena_schedule_reset(struct efx_nic *efx, enum reset_type type); 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci/* Dummy PHY ops for PHY drivers */ 6362306a36Sopenharmony_ciint efx_siena_port_dummy_op_int(struct efx_nic *efx); 6462306a36Sopenharmony_civoid efx_siena_port_dummy_op_void(struct efx_nic *efx); 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_cistatic inline int efx_check_disabled(struct efx_nic *efx) 6762306a36Sopenharmony_ci{ 6862306a36Sopenharmony_ci if (efx->state == STATE_DISABLED || efx->state == STATE_RECOVERY) { 6962306a36Sopenharmony_ci netif_err(efx, drv, efx->net_dev, 7062306a36Sopenharmony_ci "device is disabled due to earlier errors\n"); 7162306a36Sopenharmony_ci return -EIO; 7262306a36Sopenharmony_ci } 7362306a36Sopenharmony_ci return 0; 7462306a36Sopenharmony_ci} 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_cistatic inline void efx_schedule_channel(struct efx_channel *channel) 7762306a36Sopenharmony_ci{ 7862306a36Sopenharmony_ci netif_vdbg(channel->efx, intr, channel->efx->net_dev, 7962306a36Sopenharmony_ci "channel %d scheduling NAPI poll on CPU%d\n", 8062306a36Sopenharmony_ci channel->channel, raw_smp_processor_id()); 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci napi_schedule(&channel->napi_str); 8362306a36Sopenharmony_ci} 8462306a36Sopenharmony_ci 8562306a36Sopenharmony_cistatic inline void efx_schedule_channel_irq(struct efx_channel *channel) 8662306a36Sopenharmony_ci{ 8762306a36Sopenharmony_ci channel->event_test_cpu = raw_smp_processor_id(); 8862306a36Sopenharmony_ci efx_schedule_channel(channel); 8962306a36Sopenharmony_ci} 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#ifdef CONFIG_SFC_SIENA_MCDI_LOGGING 9262306a36Sopenharmony_civoid efx_siena_init_mcdi_logging(struct efx_nic *efx); 9362306a36Sopenharmony_civoid efx_siena_fini_mcdi_logging(struct efx_nic *efx); 9462306a36Sopenharmony_ci#else 9562306a36Sopenharmony_cistatic inline void efx_siena_init_mcdi_logging(struct efx_nic *efx) {} 9662306a36Sopenharmony_cistatic inline void efx_siena_fini_mcdi_logging(struct efx_nic *efx) {} 9762306a36Sopenharmony_ci#endif 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_civoid efx_siena_mac_reconfigure(struct efx_nic *efx, bool mtu_only); 10062306a36Sopenharmony_ciint efx_siena_set_mac_address(struct net_device *net_dev, void *data); 10162306a36Sopenharmony_civoid efx_siena_set_rx_mode(struct net_device *net_dev); 10262306a36Sopenharmony_ciint efx_siena_set_features(struct net_device *net_dev, netdev_features_t data); 10362306a36Sopenharmony_civoid efx_siena_link_status_changed(struct efx_nic *efx); 10462306a36Sopenharmony_ciunsigned int efx_siena_xdp_max_mtu(struct efx_nic *efx); 10562306a36Sopenharmony_ciint efx_siena_change_mtu(struct net_device *net_dev, int new_mtu); 10662306a36Sopenharmony_ci 10762306a36Sopenharmony_ciextern const struct pci_error_handlers efx_siena_err_handlers; 10862306a36Sopenharmony_ci 10962306a36Sopenharmony_cinetdev_features_t efx_siena_features_check(struct sk_buff *skb, 11062306a36Sopenharmony_ci struct net_device *dev, 11162306a36Sopenharmony_ci netdev_features_t features); 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ciint efx_siena_get_phys_port_id(struct net_device *net_dev, 11462306a36Sopenharmony_ci struct netdev_phys_item_id *ppid); 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ciint efx_siena_get_phys_port_name(struct net_device *net_dev, 11762306a36Sopenharmony_ci char *name, size_t len); 11862306a36Sopenharmony_ci#endif 119