igc_tsn.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (c) 2020 Intel Corporation */
  3. #ifndef _IGC_TSN_H_
  4. #define _IGC_TSN_H_
  5. #include <net/pkt_sched.h>
  6. #define IGC_RX_MIN_FRAG_SIZE 60
  7. #define SMD_FRAME_SIZE 60
  8. enum igc_txd_popts_type {
  9. SMD_V = 0x01,
  10. SMD_R = 0x02,
  11. };
  12. DECLARE_STATIC_KEY_FALSE(igc_fpe_enabled);
  13. void igc_fpe_init(struct igc_adapter *adapter);
  14. void igc_fpe_clear_preempt_queue(struct igc_adapter *adapter);
  15. void igc_fpe_save_preempt_queue(struct igc_adapter *adapter,
  16. const struct tc_mqprio_qopt_offload *mqprio);
  17. u32 igc_fpe_get_supported_frag_size(u32 frag_size);
  18. int igc_tsn_offload_apply(struct igc_adapter *adapter);
  19. int igc_tsn_reset(struct igc_adapter *adapter);
  20. void igc_tsn_adjust_txtime_offset(struct igc_adapter *adapter);
  21. bool igc_tsn_is_taprio_activated_by_user(struct igc_adapter *adapter);
  22. static inline bool igc_fpe_is_pmac_enabled(struct igc_adapter *adapter)
  23. {
  24. return static_branch_unlikely(&igc_fpe_enabled) &&
  25. adapter->fpe.mmsv.pmac_enabled;
  26. }
  27. static inline bool igc_fpe_handle_mpacket(struct igc_adapter *adapter,
  28. union igc_adv_rx_desc *rx_desc,
  29. unsigned int size, void *pktbuf)
  30. {
  31. u32 status_error = le32_to_cpu(rx_desc->wb.upper.status_error);
  32. int smd;
  33. smd = FIELD_GET(IGC_RXDADV_STAT_SMD_TYPE_MASK, status_error);
  34. if (smd != IGC_RXD_STAT_SMD_TYPE_V && smd != IGC_RXD_STAT_SMD_TYPE_R)
  35. return false;
  36. if (size == SMD_FRAME_SIZE && mem_is_zero(pktbuf, SMD_FRAME_SIZE)) {
  37. struct ethtool_mmsv *mmsv = &adapter->fpe.mmsv;
  38. enum ethtool_mmsv_event event;
  39. if (smd == IGC_RXD_STAT_SMD_TYPE_V)
  40. event = ETHTOOL_MMSV_LP_SENT_VERIFY_MPACKET;
  41. else
  42. event = ETHTOOL_MMSV_LP_SENT_RESPONSE_MPACKET;
  43. ethtool_mmsv_event_handle(mmsv, event);
  44. }
  45. return true;
  46. }
  47. static inline bool igc_fpe_transmitted_smd_v(union igc_adv_tx_desc *tx_desc)
  48. {
  49. u32 olinfo_status = le32_to_cpu(tx_desc->read.olinfo_status);
  50. u8 smd = FIELD_GET(IGC_TXD_POPTS_SMD_MASK, olinfo_status);
  51. return smd == SMD_V;
  52. }
  53. #endif /* _IGC_BASE_H */