mae.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /****************************************************************************
  3. * Driver for Solarflare network controllers and boards
  4. * Copyright 2019 Solarflare Communications Inc.
  5. * Copyright 2020-2022 Xilinx Inc.
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published
  9. * by the Free Software Foundation, incorporated herein by reference.
  10. */
  11. #ifndef EF100_MAE_H
  12. #define EF100_MAE_H
  13. /* MCDI interface for the ef100 Match-Action Engine */
  14. #include <net/devlink.h>
  15. #include "net_driver.h"
  16. #include "tc.h"
  17. #include "mcdi_pcol.h" /* needed for various MC_CMD_MAE_*_NULL defines */
  18. int efx_mae_allocate_mport(struct efx_nic *efx, u32 *id, u32 *label);
  19. int efx_mae_free_mport(struct efx_nic *efx, u32 id);
  20. void efx_mae_mport_wire(struct efx_nic *efx, u32 *out);
  21. void efx_mae_mport_uplink(struct efx_nic *efx, u32 *out);
  22. void efx_mae_mport_vf(struct efx_nic *efx, u32 vf_id, u32 *out);
  23. void efx_mae_mport_mport(struct efx_nic *efx, u32 mport_id, u32 *out);
  24. int efx_mae_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id);
  25. struct mae_mport_desc {
  26. u32 mport_id;
  27. u32 flags;
  28. u32 caller_flags; /* enum mae_mport_desc_caller_flags */
  29. u32 mport_type; /* MAE_MPORT_DESC_MPORT_TYPE_* */
  30. union {
  31. u32 port_idx; /* for mport_type == NET_PORT */
  32. u32 alias_mport_id; /* for mport_type == ALIAS */
  33. struct { /* for mport_type == VNIC */
  34. u32 vnic_client_type; /* MAE_MPORT_DESC_VNIC_CLIENT_TYPE_* */
  35. u32 interface_idx;
  36. u16 pf_idx;
  37. u16 vf_idx;
  38. };
  39. };
  40. struct rhash_head linkage;
  41. struct devlink_port dl_port;
  42. };
  43. int efx_mae_enumerate_mports(struct efx_nic *efx);
  44. struct mae_mport_desc *efx_mae_get_mport(struct efx_nic *efx, u32 mport_id);
  45. void efx_mae_put_mport(struct efx_nic *efx, struct mae_mport_desc *desc);
  46. /**
  47. * struct efx_mae - MAE information
  48. *
  49. * @efx: The associated NIC
  50. * @mports_ht: m-port descriptions from MC_CMD_MAE_MPORT_READ_JOURNAL
  51. */
  52. struct efx_mae {
  53. struct efx_nic *efx;
  54. struct rhashtable mports_ht;
  55. };
  56. int efx_mae_start_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue);
  57. int efx_mae_stop_counters(struct efx_nic *efx, struct efx_rx_queue *rx_queue);
  58. void efx_mae_counters_grant_credits(struct work_struct *work);
  59. int efx_mae_get_tables(struct efx_nic *efx);
  60. void efx_mae_free_tables(struct efx_nic *efx);
  61. #define MAE_NUM_FIELDS (MAE_FIELD_ENC_VNET_ID + 1)
  62. struct mae_caps {
  63. u32 match_field_count;
  64. u32 encap_types;
  65. u32 action_prios;
  66. u8 action_rule_fields[MAE_NUM_FIELDS];
  67. u8 outer_rule_fields[MAE_NUM_FIELDS];
  68. };
  69. int efx_mae_get_caps(struct efx_nic *efx, struct mae_caps *caps);
  70. int efx_mae_match_check_caps(struct efx_nic *efx,
  71. const struct efx_tc_match_fields *mask,
  72. struct netlink_ext_ack *extack);
  73. int efx_mae_match_check_caps_lhs(struct efx_nic *efx,
  74. const struct efx_tc_match_fields *mask,
  75. struct netlink_ext_ack *extack);
  76. int efx_mae_check_encap_match_caps(struct efx_nic *efx, bool ipv6,
  77. u8 ip_tos_mask, __be16 udp_sport_mask,
  78. struct netlink_ext_ack *extack);
  79. int efx_mae_check_encap_type_supported(struct efx_nic *efx,
  80. enum efx_encap_type typ);
  81. int efx_mae_allocate_counter(struct efx_nic *efx, struct efx_tc_counter *cnt);
  82. int efx_mae_free_counter(struct efx_nic *efx, struct efx_tc_counter *cnt);
  83. int efx_mae_allocate_encap_md(struct efx_nic *efx,
  84. struct efx_tc_encap_action *encap);
  85. int efx_mae_update_encap_md(struct efx_nic *efx,
  86. struct efx_tc_encap_action *encap);
  87. int efx_mae_free_encap_md(struct efx_nic *efx,
  88. struct efx_tc_encap_action *encap);
  89. int efx_mae_allocate_pedit_mac(struct efx_nic *efx,
  90. struct efx_tc_mac_pedit_action *ped);
  91. void efx_mae_free_pedit_mac(struct efx_nic *efx,
  92. struct efx_tc_mac_pedit_action *ped);
  93. int efx_mae_alloc_action_set(struct efx_nic *efx, struct efx_tc_action_set *act);
  94. int efx_mae_free_action_set(struct efx_nic *efx, u32 fw_id);
  95. int efx_mae_alloc_action_set_list(struct efx_nic *efx,
  96. struct efx_tc_action_set_list *acts);
  97. int efx_mae_free_action_set_list(struct efx_nic *efx,
  98. struct efx_tc_action_set_list *acts);
  99. int efx_mae_register_encap_match(struct efx_nic *efx,
  100. struct efx_tc_encap_match *encap);
  101. int efx_mae_unregister_encap_match(struct efx_nic *efx,
  102. struct efx_tc_encap_match *encap);
  103. int efx_mae_insert_lhs_rule(struct efx_nic *efx, struct efx_tc_lhs_rule *rule,
  104. u32 prio);
  105. int efx_mae_remove_lhs_rule(struct efx_nic *efx, struct efx_tc_lhs_rule *rule);
  106. struct efx_tc_ct_entry; /* see tc_conntrack.h */
  107. int efx_mae_insert_ct(struct efx_nic *efx, struct efx_tc_ct_entry *conn);
  108. int efx_mae_remove_ct(struct efx_nic *efx, struct efx_tc_ct_entry *conn);
  109. int efx_mae_insert_rule(struct efx_nic *efx, const struct efx_tc_match *match,
  110. u32 prio, u32 acts_id, u32 *id);
  111. int efx_mae_update_rule(struct efx_nic *efx, u32 acts_id, u32 id);
  112. int efx_mae_delete_rule(struct efx_nic *efx, u32 id);
  113. int efx_init_mae(struct efx_nic *efx);
  114. void efx_fini_mae(struct efx_nic *efx);
  115. void efx_mae_remove_mport(void *desc, void *arg);
  116. int efx_mae_fw_lookup_mport(struct efx_nic *efx, u32 selector, u32 *id);
  117. int efx_mae_lookup_mport(struct efx_nic *efx, u32 vf, u32 *id);
  118. #endif /* EF100_MAE_H */