18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/****************************************************************************
38c2ecf20Sopenharmony_ci * Driver for Solarflare network controllers and boards
48c2ecf20Sopenharmony_ci * Copyright 2018 Solarflare Communications Inc.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it
78c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License version 2 as published
88c2ecf20Sopenharmony_ci * by the Free Software Foundation, incorporated herein by reference.
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef EFX_COMMON_H
128c2ecf20Sopenharmony_ci#define EFX_COMMON_H
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciint efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask,
158c2ecf20Sopenharmony_ci		unsigned int mem_map_size);
168c2ecf20Sopenharmony_civoid efx_fini_io(struct efx_nic *efx);
178c2ecf20Sopenharmony_ciint efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev,
188c2ecf20Sopenharmony_ci		    struct net_device *net_dev);
198c2ecf20Sopenharmony_civoid efx_fini_struct(struct efx_nic *efx);
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci#define EFX_MAX_DMAQ_SIZE 4096UL
228c2ecf20Sopenharmony_ci#define EFX_DEFAULT_DMAQ_SIZE 1024UL
238c2ecf20Sopenharmony_ci#define EFX_MIN_DMAQ_SIZE 512UL
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ci#define EFX_MAX_EVQ_SIZE 16384UL
268c2ecf20Sopenharmony_ci#define EFX_MIN_EVQ_SIZE 512UL
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_civoid efx_link_clear_advertising(struct efx_nic *efx);
298c2ecf20Sopenharmony_civoid efx_link_set_wanted_fc(struct efx_nic *efx, u8);
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_civoid efx_start_all(struct efx_nic *efx);
328c2ecf20Sopenharmony_civoid efx_stop_all(struct efx_nic *efx);
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_civoid efx_net_stats(struct net_device *net_dev, struct rtnl_link_stats64 *stats);
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciint efx_create_reset_workqueue(void);
378c2ecf20Sopenharmony_civoid efx_queue_reset_work(struct efx_nic *efx);
388c2ecf20Sopenharmony_civoid efx_flush_reset_workqueue(struct efx_nic *efx);
398c2ecf20Sopenharmony_civoid efx_destroy_reset_workqueue(void);
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_civoid efx_start_monitor(struct efx_nic *efx);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciint __efx_reconfigure_port(struct efx_nic *efx);
448c2ecf20Sopenharmony_ciint efx_reconfigure_port(struct efx_nic *efx);
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci#define EFX_ASSERT_RESET_SERIALISED(efx)		\
478c2ecf20Sopenharmony_ci	do {						\
488c2ecf20Sopenharmony_ci		if (efx->state != STATE_UNINIT)		\
498c2ecf20Sopenharmony_ci			ASSERT_RTNL();			\
508c2ecf20Sopenharmony_ci	} while (0)
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciint efx_try_recovery(struct efx_nic *efx);
538c2ecf20Sopenharmony_civoid efx_reset_down(struct efx_nic *efx, enum reset_type method);
548c2ecf20Sopenharmony_civoid efx_watchdog(struct net_device *net_dev, unsigned int txqueue);
558c2ecf20Sopenharmony_ciint efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok);
568c2ecf20Sopenharmony_ciint efx_reset(struct efx_nic *efx, enum reset_type method);
578c2ecf20Sopenharmony_civoid efx_schedule_reset(struct efx_nic *efx, enum reset_type type);
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci/* Dummy PHY ops for PHY drivers */
608c2ecf20Sopenharmony_ciint efx_port_dummy_op_int(struct efx_nic *efx);
618c2ecf20Sopenharmony_civoid efx_port_dummy_op_void(struct efx_nic *efx);
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_cistatic inline int efx_check_disabled(struct efx_nic *efx)
648c2ecf20Sopenharmony_ci{
658c2ecf20Sopenharmony_ci	if (efx->state == STATE_DISABLED || efx_recovering(efx->state)) {
668c2ecf20Sopenharmony_ci		netif_err(efx, drv, efx->net_dev,
678c2ecf20Sopenharmony_ci			  "device is disabled due to earlier errors\n");
688c2ecf20Sopenharmony_ci		return -EIO;
698c2ecf20Sopenharmony_ci	}
708c2ecf20Sopenharmony_ci	return 0;
718c2ecf20Sopenharmony_ci}
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_cistatic inline void efx_schedule_channel(struct efx_channel *channel)
748c2ecf20Sopenharmony_ci{
758c2ecf20Sopenharmony_ci	netif_vdbg(channel->efx, intr, channel->efx->net_dev,
768c2ecf20Sopenharmony_ci		   "channel %d scheduling NAPI poll on CPU%d\n",
778c2ecf20Sopenharmony_ci		   channel->channel, raw_smp_processor_id());
788c2ecf20Sopenharmony_ci
798c2ecf20Sopenharmony_ci	napi_schedule(&channel->napi_str);
808c2ecf20Sopenharmony_ci}
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_cistatic inline void efx_schedule_channel_irq(struct efx_channel *channel)
838c2ecf20Sopenharmony_ci{
848c2ecf20Sopenharmony_ci	channel->event_test_cpu = raw_smp_processor_id();
858c2ecf20Sopenharmony_ci	efx_schedule_channel(channel);
868c2ecf20Sopenharmony_ci}
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci#ifdef CONFIG_SFC_MCDI_LOGGING
898c2ecf20Sopenharmony_civoid efx_init_mcdi_logging(struct efx_nic *efx);
908c2ecf20Sopenharmony_civoid efx_fini_mcdi_logging(struct efx_nic *efx);
918c2ecf20Sopenharmony_ci#else
928c2ecf20Sopenharmony_cistatic inline void efx_init_mcdi_logging(struct efx_nic *efx) {}
938c2ecf20Sopenharmony_cistatic inline void efx_fini_mcdi_logging(struct efx_nic *efx) {}
948c2ecf20Sopenharmony_ci#endif
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_civoid efx_mac_reconfigure(struct efx_nic *efx, bool mtu_only);
978c2ecf20Sopenharmony_ciint efx_set_mac_address(struct net_device *net_dev, void *data);
988c2ecf20Sopenharmony_civoid efx_set_rx_mode(struct net_device *net_dev);
998c2ecf20Sopenharmony_ciint efx_set_features(struct net_device *net_dev, netdev_features_t data);
1008c2ecf20Sopenharmony_civoid efx_link_status_changed(struct efx_nic *efx);
1018c2ecf20Sopenharmony_ciunsigned int efx_xdp_max_mtu(struct efx_nic *efx);
1028c2ecf20Sopenharmony_ciint efx_change_mtu(struct net_device *net_dev, int new_mtu);
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ciextern const struct pci_error_handlers efx_err_handlers;
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cinetdev_features_t efx_features_check(struct sk_buff *skb, struct net_device *dev,
1078c2ecf20Sopenharmony_ci				     netdev_features_t features);
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ciint efx_get_phys_port_id(struct net_device *net_dev,
1108c2ecf20Sopenharmony_ci			 struct netdev_phys_item_id *ppid);
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ciint efx_get_phys_port_name(struct net_device *net_dev,
1138c2ecf20Sopenharmony_ci			   char *name, size_t len);
1148c2ecf20Sopenharmony_ci#endif
115