rx_common.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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_RX_COMMON_H
  11. #define EFX_RX_COMMON_H
  12. /* Preferred number of descriptors to fill at once */
  13. #define EFX_RX_PREFERRED_BATCH 8U
  14. /* Each packet can consume up to ceil(max_frame_len / buffer_size) buffers */
  15. #define EFX_RX_MAX_FRAGS DIV_ROUND_UP(EFX_MAX_FRAME_LEN(EFX_MAX_MTU), \
  16. EFX_RX_USR_BUF_SIZE)
  17. /* Number of RX buffers to recycle pages for. When creating the RX page recycle
  18. * ring, this number is divided by the number of buffers per page to calculate
  19. * the number of pages to store in the RX page recycle ring.
  20. */
  21. #define EFX_RECYCLE_RING_SIZE_10G 256
  22. static inline u8 *efx_rx_buf_va(struct efx_rx_buffer *buf)
  23. {
  24. return page_address(buf->page) + buf->page_offset;
  25. }
  26. static inline u32 efx_rx_buf_hash(struct efx_nic *efx, const u8 *eh)
  27. {
  28. #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
  29. return __le32_to_cpup((const __le32 *)(eh + efx->rx_packet_hash_offset));
  30. #else
  31. const u8 *data = eh + efx->rx_packet_hash_offset;
  32. return (u32)data[0] |
  33. (u32)data[1] << 8 |
  34. (u32)data[2] << 16 |
  35. (u32)data[3] << 24;
  36. #endif
  37. }
  38. void efx_siena_rx_slow_fill(struct timer_list *t);
  39. void efx_siena_recycle_rx_pages(struct efx_channel *channel,
  40. struct efx_rx_buffer *rx_buf,
  41. unsigned int n_frags);
  42. void efx_siena_discard_rx_packet(struct efx_channel *channel,
  43. struct efx_rx_buffer *rx_buf,
  44. unsigned int n_frags);
  45. int efx_siena_probe_rx_queue(struct efx_rx_queue *rx_queue);
  46. void efx_siena_init_rx_queue(struct efx_rx_queue *rx_queue);
  47. void efx_siena_fini_rx_queue(struct efx_rx_queue *rx_queue);
  48. void efx_siena_remove_rx_queue(struct efx_rx_queue *rx_queue);
  49. static inline void efx_sync_rx_buffer(struct efx_nic *efx,
  50. struct efx_rx_buffer *rx_buf,
  51. unsigned int len)
  52. {
  53. dma_sync_single_for_cpu(&efx->pci_dev->dev, rx_buf->dma_addr, len,
  54. DMA_FROM_DEVICE);
  55. }
  56. void efx_siena_free_rx_buffers(struct efx_rx_queue *rx_queue,
  57. struct efx_rx_buffer *rx_buf,
  58. unsigned int num_bufs);
  59. void efx_siena_rx_config_page_split(struct efx_nic *efx);
  60. void efx_siena_fast_push_rx_descriptors(struct efx_rx_queue *rx_queue,
  61. bool atomic);
  62. void
  63. efx_siena_rx_packet_gro(struct efx_channel *channel,
  64. struct efx_rx_buffer *rx_buf,
  65. unsigned int n_frags, u8 *eh, __wsum csum);
  66. void efx_siena_set_default_rx_indir_table(struct efx_nic *efx,
  67. struct efx_rss_context *ctx);
  68. bool efx_siena_filter_is_mc_recipient(const struct efx_filter_spec *spec);
  69. bool efx_siena_filter_spec_equal(const struct efx_filter_spec *left,
  70. const struct efx_filter_spec *right);
  71. u32 efx_siena_filter_spec_hash(const struct efx_filter_spec *spec);
  72. #ifdef CONFIG_RFS_ACCEL
  73. bool efx_siena_rps_check_rule(struct efx_arfs_rule *rule,
  74. unsigned int filter_idx, bool *force);
  75. struct efx_arfs_rule *efx_siena_rps_hash_find(struct efx_nic *efx,
  76. const struct efx_filter_spec *spec);
  77. void efx_siena_rps_hash_del(struct efx_nic *efx,
  78. const struct efx_filter_spec *spec);
  79. int efx_siena_filter_rfs(struct net_device *net_dev, const struct sk_buff *skb,
  80. u16 rxq_index, u32 flow_id);
  81. bool __efx_siena_filter_rfs_expire(struct efx_channel *channel,
  82. unsigned int quota);
  83. #endif
  84. int efx_siena_probe_filters(struct efx_nic *efx);
  85. void efx_siena_remove_filters(struct efx_nic *efx);
  86. #endif