PageRenderTime 49ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/net/ethernet/intel/ice/ice_tc_lib.h

https://github.com/tiwai/sound
C Header | 165 lines | 113 code | 22 blank | 30 comment | 0 complexity | b832c486db1555b518ca96325e4caf67 MD5 | raw file
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2019-2021, Intel Corporation. */
  3. #ifndef _ICE_TC_LIB_H_
  4. #define _ICE_TC_LIB_H_
  5. #define ICE_TC_FLWR_FIELD_DST_MAC BIT(0)
  6. #define ICE_TC_FLWR_FIELD_SRC_MAC BIT(1)
  7. #define ICE_TC_FLWR_FIELD_VLAN BIT(2)
  8. #define ICE_TC_FLWR_FIELD_DEST_IPV4 BIT(3)
  9. #define ICE_TC_FLWR_FIELD_SRC_IPV4 BIT(4)
  10. #define ICE_TC_FLWR_FIELD_DEST_IPV6 BIT(5)
  11. #define ICE_TC_FLWR_FIELD_SRC_IPV6 BIT(6)
  12. #define ICE_TC_FLWR_FIELD_DEST_L4_PORT BIT(7)
  13. #define ICE_TC_FLWR_FIELD_SRC_L4_PORT BIT(8)
  14. #define ICE_TC_FLWR_FIELD_TENANT_ID BIT(9)
  15. #define ICE_TC_FLWR_FIELD_ENC_DEST_IPV4 BIT(10)
  16. #define ICE_TC_FLWR_FIELD_ENC_SRC_IPV4 BIT(11)
  17. #define ICE_TC_FLWR_FIELD_ENC_DEST_IPV6 BIT(12)
  18. #define ICE_TC_FLWR_FIELD_ENC_SRC_IPV6 BIT(13)
  19. #define ICE_TC_FLWR_FIELD_ENC_DEST_L4_PORT BIT(14)
  20. #define ICE_TC_FLWR_FIELD_ENC_SRC_L4_PORT BIT(15)
  21. #define ICE_TC_FLWR_FIELD_ENC_DST_MAC BIT(16)
  22. #define ICE_TC_FLWR_FIELD_ETH_TYPE_ID BIT(17)
  23. #define ICE_TC_FLWR_FIELD_ENC_OPTS BIT(18)
  24. #define ICE_TC_FLOWER_MASK_32 0xFFFFFFFF
  25. struct ice_indr_block_priv {
  26. struct net_device *netdev;
  27. struct ice_netdev_priv *np;
  28. struct list_head list;
  29. };
  30. struct ice_tc_flower_action {
  31. u32 tc_class;
  32. enum ice_sw_fwd_act_type fltr_act;
  33. };
  34. struct ice_tc_vlan_hdr {
  35. __be16 vlan_id; /* Only last 12 bits valid */
  36. u16 vlan_prio; /* Only last 3 bits valid (valid values: 0..7) */
  37. };
  38. struct ice_tc_l2_hdr {
  39. u8 dst_mac[ETH_ALEN];
  40. u8 src_mac[ETH_ALEN];
  41. __be16 n_proto; /* Ethernet Protocol */
  42. };
  43. struct ice_tc_l3_hdr {
  44. u8 ip_proto; /* IPPROTO value */
  45. union {
  46. struct {
  47. struct in_addr dst_ip;
  48. struct in_addr src_ip;
  49. } v4;
  50. struct {
  51. struct in6_addr dst_ip6;
  52. struct in6_addr src_ip6;
  53. } v6;
  54. } ip;
  55. #define dst_ipv6 ip.v6.dst_ip6.s6_addr32
  56. #define dst_ipv6_addr ip.v6.dst_ip6.s6_addr
  57. #define src_ipv6 ip.v6.src_ip6.s6_addr32
  58. #define src_ipv6_addr ip.v6.src_ip6.s6_addr
  59. #define dst_ipv4 ip.v4.dst_ip.s_addr
  60. #define src_ipv4 ip.v4.src_ip.s_addr
  61. u8 tos;
  62. u8 ttl;
  63. };
  64. struct ice_tc_l4_hdr {
  65. __be16 dst_port;
  66. __be16 src_port;
  67. };
  68. struct ice_tc_flower_lyr_2_4_hdrs {
  69. /* L2 layer fields with their mask */
  70. struct ice_tc_l2_hdr l2_key;
  71. struct ice_tc_l2_hdr l2_mask;
  72. struct ice_tc_vlan_hdr vlan_hdr;
  73. /* L3 (IPv4[6]) layer fields with their mask */
  74. struct ice_tc_l3_hdr l3_key;
  75. struct ice_tc_l3_hdr l3_mask;
  76. /* L4 layer fields with their mask */
  77. struct ice_tc_l4_hdr l4_key;
  78. struct ice_tc_l4_hdr l4_mask;
  79. };
  80. enum ice_eswitch_fltr_direction {
  81. ICE_ESWITCH_FLTR_INGRESS,
  82. ICE_ESWITCH_FLTR_EGRESS,
  83. };
  84. struct ice_tc_flower_fltr {
  85. struct hlist_node tc_flower_node;
  86. /* cookie becomes filter_rule_id if rule is added successfully */
  87. unsigned long cookie;
  88. /* add_adv_rule returns information like recipe ID, rule_id. Store
  89. * those values since they are needed to remove advanced rule
  90. */
  91. u16 rid;
  92. u16 rule_id;
  93. /* this could be queue/vsi_idx (sw handle)/queue_group, depending upon
  94. * destination type
  95. */
  96. u16 dest_id;
  97. /* if dest_id is vsi_idx, then need to store destination VSI ptr */
  98. struct ice_vsi *dest_vsi;
  99. /* direction of fltr for eswitch use case */
  100. enum ice_eswitch_fltr_direction direction;
  101. /* Parsed TC flower configuration params */
  102. struct ice_tc_flower_lyr_2_4_hdrs outer_headers;
  103. struct ice_tc_flower_lyr_2_4_hdrs inner_headers;
  104. struct ice_vsi *src_vsi;
  105. __be32 tenant_id;
  106. struct gtp_pdu_session_info gtp_pdu_info_keys;
  107. struct gtp_pdu_session_info gtp_pdu_info_masks;
  108. u32 flags;
  109. u8 tunnel_type;
  110. struct ice_tc_flower_action action;
  111. /* cache ptr which is used wherever needed to communicate netlink
  112. * messages
  113. */
  114. struct netlink_ext_ack *extack;
  115. };
  116. /**
  117. * ice_is_chnl_fltr - is this a valid channel filter
  118. * @f: Pointer to tc-flower filter
  119. *
  120. * Criteria to determine of given filter is valid channel filter
  121. * or not is based on its "destination". If destination is hw_tc (aka tc_class)
  122. * and it is non-zero, then it is valid channel (aka ADQ) filter
  123. */
  124. static inline bool ice_is_chnl_fltr(struct ice_tc_flower_fltr *f)
  125. {
  126. return !!f->action.tc_class;
  127. }
  128. /**
  129. * ice_chnl_dmac_fltr_cnt - DMAC based CHNL filter count
  130. * @pf: Pointer to PF
  131. */
  132. static inline int ice_chnl_dmac_fltr_cnt(struct ice_pf *pf)
  133. {
  134. return pf->num_dmac_chnl_fltrs;
  135. }
  136. int
  137. ice_add_cls_flower(struct net_device *netdev, struct ice_vsi *vsi,
  138. struct flow_cls_offload *cls_flower);
  139. int
  140. ice_del_cls_flower(struct ice_vsi *vsi, struct flow_cls_offload *cls_flower);
  141. void ice_replay_tc_fltrs(struct ice_pf *pf);
  142. bool ice_is_tunnel_supported(struct net_device *dev);
  143. #endif /* _ICE_TC_LIB_H_ */