efx_common.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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. #ifndef EFX_COMMON_H
  11. #define EFX_COMMON_H
  12. int efx_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask,
  13. unsigned int mem_map_size);
  14. void efx_fini_io(struct efx_nic *efx);
  15. int efx_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev);
  16. void efx_fini_struct(struct efx_nic *efx);
  17. #define EFX_MAX_DMAQ_SIZE 4096UL
  18. #define EFX_DEFAULT_DMAQ_SIZE 1024UL
  19. #define EFX_MIN_DMAQ_SIZE 512UL
  20. #define EFX_MAX_EVQ_SIZE 16384UL
  21. #define EFX_MIN_EVQ_SIZE 512UL
  22. void efx_link_clear_advertising(struct efx_nic *efx);
  23. void efx_link_set_wanted_fc(struct efx_nic *efx, u8);
  24. void efx_start_all(struct efx_nic *efx);
  25. void efx_stop_all(struct efx_nic *efx);
  26. void efx_net_stats(struct net_device *net_dev, struct rtnl_link_stats64 *stats);
  27. int efx_create_reset_workqueue(void);
  28. void efx_queue_reset_work(struct efx_nic *efx);
  29. void efx_flush_reset_workqueue(struct efx_nic *efx);
  30. void efx_destroy_reset_workqueue(void);
  31. void efx_start_monitor(struct efx_nic *efx);
  32. int __efx_reconfigure_port(struct efx_nic *efx);
  33. int efx_reconfigure_port(struct efx_nic *efx);
  34. #define EFX_ASSERT_RESET_SERIALISED(efx) \
  35. do { \
  36. if ((efx)->state != STATE_UNINIT && \
  37. (efx)->state != STATE_PROBED) \
  38. ASSERT_RTNL(); \
  39. } while (0)
  40. int efx_try_recovery(struct efx_nic *efx);
  41. void efx_reset_down(struct efx_nic *efx, enum reset_type method);
  42. void efx_watchdog(struct net_device *net_dev, unsigned int txqueue);
  43. int efx_reset_up(struct efx_nic *efx, enum reset_type method, bool ok);
  44. int efx_reset(struct efx_nic *efx, enum reset_type method);
  45. void efx_schedule_reset(struct efx_nic *efx, enum reset_type type);
  46. /* Dummy PHY ops for PHY drivers */
  47. int efx_port_dummy_op_int(struct efx_nic *efx);
  48. void efx_port_dummy_op_void(struct efx_nic *efx);
  49. static inline int efx_check_disabled(struct efx_nic *efx)
  50. {
  51. if (efx->state == STATE_DISABLED || efx_recovering(efx->state)) {
  52. netif_err(efx, drv, efx->net_dev,
  53. "device is disabled due to earlier errors\n");
  54. return -EIO;
  55. }
  56. return 0;
  57. }
  58. static inline void efx_schedule_channel(struct efx_channel *channel)
  59. {
  60. netif_vdbg(channel->efx, intr, channel->efx->net_dev,
  61. "channel %d scheduling NAPI poll on CPU%d\n",
  62. channel->channel, raw_smp_processor_id());
  63. napi_schedule(&channel->napi_str);
  64. }
  65. static inline void efx_schedule_channel_irq(struct efx_channel *channel)
  66. {
  67. channel->event_test_cpu = raw_smp_processor_id();
  68. efx_schedule_channel(channel);
  69. }
  70. #ifdef CONFIG_SFC_MCDI_LOGGING
  71. void efx_init_mcdi_logging(struct efx_nic *efx);
  72. void efx_fini_mcdi_logging(struct efx_nic *efx);
  73. #else
  74. static inline void efx_init_mcdi_logging(struct efx_nic *efx) {}
  75. static inline void efx_fini_mcdi_logging(struct efx_nic *efx) {}
  76. #endif
  77. void efx_mac_reconfigure(struct efx_nic *efx, bool mtu_only);
  78. int efx_set_mac_address(struct net_device *net_dev, void *data);
  79. void efx_set_rx_mode(struct net_device *net_dev);
  80. int efx_set_features(struct net_device *net_dev, netdev_features_t data);
  81. void efx_link_status_changed(struct efx_nic *efx);
  82. unsigned int efx_xdp_max_mtu(struct efx_nic *efx);
  83. int efx_change_mtu(struct net_device *net_dev, int new_mtu);
  84. extern const struct pci_error_handlers efx_err_handlers;
  85. netdev_features_t efx_features_check(struct sk_buff *skb, struct net_device *dev,
  86. netdev_features_t features);
  87. int efx_get_phys_port_id(struct net_device *net_dev,
  88. struct netdev_phys_item_id *ppid);
  89. int efx_get_phys_port_name(struct net_device *net_dev,
  90. char *name, size_t len);
  91. void efx_detach_reps(struct efx_nic *efx);
  92. void efx_attach_reps(struct efx_nic *efx);
  93. #endif