efx_common.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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_siena_init_io(struct efx_nic *efx, int bar, dma_addr_t dma_mask,
  13. unsigned int mem_map_size);
  14. void efx_siena_fini_io(struct efx_nic *efx);
  15. int efx_siena_init_struct(struct efx_nic *efx, struct pci_dev *pci_dev,
  16. struct net_device *net_dev);
  17. void efx_siena_fini_struct(struct efx_nic *efx);
  18. #define EFX_MAX_DMAQ_SIZE 4096UL
  19. #define EFX_DEFAULT_DMAQ_SIZE 1024UL
  20. #define EFX_MIN_DMAQ_SIZE 512UL
  21. #define EFX_MAX_EVQ_SIZE 16384UL
  22. #define EFX_MIN_EVQ_SIZE 512UL
  23. void efx_siena_link_clear_advertising(struct efx_nic *efx);
  24. void efx_siena_link_set_wanted_fc(struct efx_nic *efx, u8 wanted_fc);
  25. void efx_siena_start_all(struct efx_nic *efx);
  26. void efx_siena_stop_all(struct efx_nic *efx);
  27. void efx_siena_net_stats(struct net_device *net_dev,
  28. struct rtnl_link_stats64 *stats);
  29. int efx_siena_create_reset_workqueue(void);
  30. void efx_siena_queue_reset_work(struct efx_nic *efx);
  31. void efx_siena_flush_reset_workqueue(struct efx_nic *efx);
  32. void efx_siena_destroy_reset_workqueue(void);
  33. void efx_siena_start_monitor(struct efx_nic *efx);
  34. int __efx_siena_reconfigure_port(struct efx_nic *efx);
  35. int efx_siena_reconfigure_port(struct efx_nic *efx);
  36. #define EFX_ASSERT_RESET_SERIALISED(efx) \
  37. do { \
  38. if ((efx->state == STATE_READY) || \
  39. (efx->state == STATE_RECOVERY) || \
  40. (efx->state == STATE_DISABLED)) \
  41. ASSERT_RTNL(); \
  42. } while (0)
  43. int efx_siena_try_recovery(struct efx_nic *efx);
  44. void efx_siena_reset_down(struct efx_nic *efx, enum reset_type method);
  45. void efx_siena_watchdog(struct net_device *net_dev, unsigned int txqueue);
  46. int efx_siena_reset_up(struct efx_nic *efx, enum reset_type method, bool ok);
  47. int efx_siena_reset(struct efx_nic *efx, enum reset_type method);
  48. void efx_siena_schedule_reset(struct efx_nic *efx, enum reset_type type);
  49. /* Dummy PHY ops for PHY drivers */
  50. int efx_siena_port_dummy_op_int(struct efx_nic *efx);
  51. void efx_siena_port_dummy_op_void(struct efx_nic *efx);
  52. static inline int efx_check_disabled(struct efx_nic *efx)
  53. {
  54. if (efx->state == STATE_DISABLED || efx->state == STATE_RECOVERY) {
  55. netif_err(efx, drv, efx->net_dev,
  56. "device is disabled due to earlier errors\n");
  57. return -EIO;
  58. }
  59. return 0;
  60. }
  61. static inline void efx_schedule_channel(struct efx_channel *channel)
  62. {
  63. netif_vdbg(channel->efx, intr, channel->efx->net_dev,
  64. "channel %d scheduling NAPI poll on CPU%d\n",
  65. channel->channel, raw_smp_processor_id());
  66. napi_schedule(&channel->napi_str);
  67. }
  68. static inline void efx_schedule_channel_irq(struct efx_channel *channel)
  69. {
  70. channel->event_test_cpu = raw_smp_processor_id();
  71. efx_schedule_channel(channel);
  72. }
  73. #ifdef CONFIG_SFC_SIENA_MCDI_LOGGING
  74. void efx_siena_init_mcdi_logging(struct efx_nic *efx);
  75. void efx_siena_fini_mcdi_logging(struct efx_nic *efx);
  76. #else
  77. static inline void efx_siena_init_mcdi_logging(struct efx_nic *efx) {}
  78. static inline void efx_siena_fini_mcdi_logging(struct efx_nic *efx) {}
  79. #endif
  80. void efx_siena_mac_reconfigure(struct efx_nic *efx, bool mtu_only);
  81. int efx_siena_set_mac_address(struct net_device *net_dev, void *data);
  82. void efx_siena_set_rx_mode(struct net_device *net_dev);
  83. int efx_siena_set_features(struct net_device *net_dev, netdev_features_t data);
  84. void efx_siena_link_status_changed(struct efx_nic *efx);
  85. unsigned int efx_siena_xdp_max_mtu(struct efx_nic *efx);
  86. int efx_siena_change_mtu(struct net_device *net_dev, int new_mtu);
  87. extern const struct pci_error_handlers efx_siena_err_handlers;
  88. netdev_features_t efx_siena_features_check(struct sk_buff *skb,
  89. struct net_device *dev,
  90. netdev_features_t features);
  91. int efx_siena_get_phys_port_id(struct net_device *net_dev,
  92. struct netdev_phys_item_id *ppid);
  93. int efx_siena_get_phys_port_name(struct net_device *net_dev,
  94. char *name, size_t len);
  95. #endif