i40e_txrx_common.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright(c) 2018 Intel Corporation. */
  3. #ifndef I40E_TXRX_COMMON_
  4. #define I40E_TXRX_COMMON_
  5. void i40e_fd_handle_status(struct i40e_ring *rx_ring,
  6. union i40e_rx_desc *rx_desc, u8 prog_id);
  7. int i40e_xmit_xdp_tx_ring(struct xdp_buff *xdp, struct i40e_ring *xdp_ring);
  8. struct i40e_rx_buffer *i40e_clean_programming_status(
  9. struct i40e_ring *rx_ring,
  10. union i40e_rx_desc *rx_desc,
  11. u64 qw);
  12. void i40e_process_skb_fields(struct i40e_ring *rx_ring,
  13. union i40e_rx_desc *rx_desc, struct sk_buff *skb,
  14. u8 rx_ptype);
  15. void i40e_receive_skb(struct i40e_ring *rx_ring,
  16. struct sk_buff *skb, u16 vlan_tag);
  17. void i40e_xdp_ring_update_tail(struct i40e_ring *xdp_ring);
  18. void i40e_update_rx_stats(struct i40e_ring *rx_ring,
  19. unsigned int total_rx_bytes,
  20. unsigned int total_rx_packets);
  21. void i40e_finalize_xdp_rx(struct i40e_ring *rx_ring, unsigned int xdp_res);
  22. void i40e_release_rx_desc(struct i40e_ring *rx_ring, u32 val);
  23. #define I40E_XDP_PASS 0
  24. #define I40E_XDP_CONSUMED BIT(0)
  25. #define I40E_XDP_TX BIT(1)
  26. #define I40E_XDP_REDIR BIT(2)
  27. /**
  28. * build_ctob - Builds the Tx descriptor (cmd, offset and type) qword
  29. **/
  30. static inline __le64 build_ctob(u32 td_cmd, u32 td_offset, unsigned int size,
  31. u32 td_tag)
  32. {
  33. return cpu_to_le64(I40E_TX_DESC_DTYPE_DATA |
  34. ((u64)td_cmd << I40E_TXD_QW1_CMD_SHIFT) |
  35. ((u64)td_offset << I40E_TXD_QW1_OFFSET_SHIFT) |
  36. ((u64)size << I40E_TXD_QW1_TX_BUF_SZ_SHIFT) |
  37. ((u64)td_tag << I40E_TXD_QW1_L2TAG1_SHIFT));
  38. }
  39. /**
  40. * i40e_update_tx_stats - Update the egress statistics for the Tx ring
  41. * @tx_ring: Tx ring to update
  42. * @total_packet: total packets sent
  43. * @total_bytes: total bytes sent
  44. **/
  45. static inline void i40e_update_tx_stats(struct i40e_ring *tx_ring,
  46. unsigned int total_packets,
  47. unsigned int total_bytes)
  48. {
  49. u64_stats_update_begin(&tx_ring->syncp);
  50. tx_ring->stats.bytes += total_bytes;
  51. tx_ring->stats.packets += total_packets;
  52. u64_stats_update_end(&tx_ring->syncp);
  53. tx_ring->q_vector->tx.total_bytes += total_bytes;
  54. tx_ring->q_vector->tx.total_packets += total_packets;
  55. }
  56. #define WB_STRIDE 4
  57. /**
  58. * i40e_arm_wb - (Possibly) arms Tx write-back
  59. * @tx_ring: Tx ring to update
  60. * @vsi: the VSI
  61. * @budget: the NAPI budget left
  62. **/
  63. static inline void i40e_arm_wb(struct i40e_ring *tx_ring,
  64. struct i40e_vsi *vsi,
  65. int budget)
  66. {
  67. if (tx_ring->flags & I40E_TXR_FLAGS_WB_ON_ITR) {
  68. /* check to see if there are < 4 descriptors
  69. * waiting to be written back, then kick the hardware to force
  70. * them to be written back in case we stay in NAPI.
  71. * In this mode on X722 we do not enable Interrupt.
  72. */
  73. unsigned int j = i40e_get_tx_pending(tx_ring, false);
  74. if (budget &&
  75. ((j / WB_STRIDE) == 0) && j > 0 &&
  76. !test_bit(__I40E_VSI_DOWN, vsi->state) &&
  77. (I40E_DESC_UNUSED(tx_ring) != tx_ring->count))
  78. tx_ring->arm_wb = true;
  79. }
  80. }
  81. void i40e_xsk_clean_rx_ring(struct i40e_ring *rx_ring);
  82. void i40e_xsk_clean_tx_ring(struct i40e_ring *tx_ring);
  83. bool i40e_xsk_any_rx_ring_enabled(struct i40e_vsi *vsi);
  84. #endif /* I40E_TXRX_COMMON_ */