fbnic_netdev.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) Meta Platforms, Inc. and affiliates. */
  3. #ifndef _FBNIC_NETDEV_H_
  4. #define _FBNIC_NETDEV_H_
  5. #include <linux/phylink.h>
  6. #include <linux/types.h>
  7. #include "fbnic_csr.h"
  8. #include "fbnic_rpc.h"
  9. #include "fbnic_txrx.h"
  10. #define FBNIC_MAX_NAPI_VECTORS 128u
  11. #define FBNIC_MIN_RXD_PER_FRAME 2
  12. /* Natively supported tunnel GSO features (not thru GSO_PARTIAL) */
  13. #define FBNIC_TUN_GSO_FEATURES NETIF_F_GSO_IPXIP6
  14. struct fbnic_net {
  15. struct bpf_prog *xdp_prog;
  16. struct fbnic_ring *tx[FBNIC_MAX_TXQS + FBNIC_MAX_XDPQS];
  17. struct fbnic_ring *rx[FBNIC_MAX_RXQS];
  18. struct fbnic_napi_vector *napi[FBNIC_MAX_NAPI_VECTORS];
  19. struct net_device *netdev;
  20. struct fbnic_dev *fbd;
  21. u32 txq_size;
  22. u32 hpq_size;
  23. u32 ppq_size;
  24. u32 rcq_size;
  25. u32 hds_thresh;
  26. u16 rx_usecs;
  27. u16 tx_usecs;
  28. u32 rx_max_frames;
  29. u16 num_napi;
  30. struct phylink *phylink;
  31. struct phylink_config phylink_config;
  32. struct phylink_pcs *pcs;
  33. u8 aui;
  34. u8 fec;
  35. /* Cached top bits of the HW time counter for 40b -> 64b conversion */
  36. u32 time_high;
  37. /* Protect readers of @time_offset, writers take @time_lock. */
  38. struct u64_stats_sync time_seq;
  39. /* Offset in ns between free running NIC PHC and time set via PTP
  40. * clock callbacks
  41. */
  42. s64 time_offset;
  43. u16 num_tx_queues;
  44. u16 num_rx_queues;
  45. u8 indir_tbl[FBNIC_RPC_RSS_TBL_COUNT][FBNIC_RPC_RSS_TBL_SIZE];
  46. u32 rss_key[FBNIC_RPC_RSS_KEY_DWORD_LEN];
  47. u32 rss_flow_hash[FBNIC_NUM_HASH_OPT];
  48. /* Storage for stats after ring destruction */
  49. struct fbnic_queue_stats tx_stats;
  50. struct fbnic_queue_stats rx_stats;
  51. struct fbnic_queue_stats bdq_stats;
  52. u64 link_down_events;
  53. /* Time stamping filter config */
  54. struct kernel_hwtstamp_config hwtstamp_config;
  55. bool tx_pause;
  56. };
  57. int __fbnic_open(struct fbnic_net *fbn);
  58. void fbnic_up(struct fbnic_net *fbn);
  59. void fbnic_down(struct fbnic_net *fbn);
  60. void fbnic_down_noidle(struct fbnic_net *fbn);
  61. struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd);
  62. void fbnic_netdev_free(struct fbnic_dev *fbd);
  63. int fbnic_netdev_register(struct net_device *netdev);
  64. void fbnic_netdev_unregister(struct net_device *netdev);
  65. void fbnic_reset_queues(struct fbnic_net *fbn,
  66. unsigned int tx, unsigned int rx);
  67. void fbnic_set_ethtool_ops(struct net_device *dev);
  68. int fbnic_ptp_setup(struct fbnic_dev *fbd);
  69. void fbnic_ptp_destroy(struct fbnic_dev *fbd);
  70. void fbnic_time_init(struct fbnic_net *fbn);
  71. int fbnic_time_start(struct fbnic_net *fbn);
  72. void fbnic_time_stop(struct fbnic_net *fbn);
  73. void __fbnic_set_rx_mode(struct fbnic_dev *fbd);
  74. void fbnic_clear_rx_mode(struct fbnic_dev *fbd);
  75. void fbnic_phylink_get_pauseparam(struct net_device *netdev,
  76. struct ethtool_pauseparam *pause);
  77. int fbnic_phylink_set_pauseparam(struct net_device *netdev,
  78. struct ethtool_pauseparam *pause);
  79. int fbnic_phylink_ethtool_ksettings_get(struct net_device *netdev,
  80. struct ethtool_link_ksettings *cmd);
  81. int fbnic_phylink_get_fecparam(struct net_device *netdev,
  82. struct ethtool_fecparam *fecparam);
  83. int fbnic_phylink_create(struct net_device *netdev);
  84. void fbnic_phylink_destroy(struct net_device *netdev);
  85. int fbnic_phylink_init(struct net_device *netdev);
  86. void fbnic_phylink_pmd_training_complete_notify(struct net_device *netdev);
  87. bool fbnic_check_split_frames(struct bpf_prog *prog,
  88. unsigned int mtu, u32 hds_threshold);
  89. #endif /* _FBNIC_NETDEV_H_ */