| 992 | } |
| 993 | |
| 994 | int |
| 995 | sfc_mae_counter_get(struct sfc_adapter *sa, |
| 996 | const struct sfc_mae_counter *counter, |
| 997 | struct rte_flow_query_count *data) |
| 998 | { |
| 999 | struct sfc_ft_ctx *ft_ctx = counter->ft_ctx; |
| 1000 | struct sfc_mae_counter_records *counters; |
| 1001 | uint64_t non_reset_tunnel_hit_counter; |
| 1002 | struct sfc_mae_counter_record *p; |
| 1003 | union sfc_pkts_bytes value; |
| 1004 | bool need_byte_count; |
| 1005 | |
| 1006 | switch (counter->type) { |
| 1007 | case EFX_COUNTER_TYPE_ACTION: |
| 1008 | counters = &sa->mae.counter_registry.action_counters; |
| 1009 | need_byte_count = true; |
| 1010 | break; |
| 1011 | case EFX_COUNTER_TYPE_CONNTRACK: |
| 1012 | counters = &sa->mae.counter_registry.conntrack_counters; |
| 1013 | need_byte_count = false; |
| 1014 | break; |
| 1015 | default: |
| 1016 | return EINVAL; |
| 1017 | } |
| 1018 | |
| 1019 | SFC_ASSERT(counter->fw_rsrc.counter_id.id < counters->n_mae_counters); |
| 1020 | p = &counters->mae_counters[counter->fw_rsrc.counter_id.id]; |
| 1021 | |
| 1022 | /* |
| 1023 | * Ordering is relaxed since it is the only operation on counter value. |
| 1024 | * And it does not depend on different stores/loads in other threads. |
| 1025 | * Paired with relaxed ordering in counter increment. |
| 1026 | */ |
| 1027 | value.pkts_bytes.int128 = __atomic_load_n(&p->value.pkts_bytes.int128, |
| 1028 | __ATOMIC_RELAXED); |
| 1029 | |
| 1030 | data->hits_set = 1; |
| 1031 | data->hits = value.pkts - p->reset.pkts; |
| 1032 | |
| 1033 | if (ft_ctx != NULL) { |
| 1034 | data->hits += ft_ctx->switch_hit_counter; |
| 1035 | non_reset_tunnel_hit_counter = data->hits; |
| 1036 | data->hits -= ft_ctx->reset_tunnel_hit_counter; |
| 1037 | } else if (need_byte_count) { |
| 1038 | data->bytes_set = 1; |
| 1039 | data->bytes = value.bytes - p->reset.bytes; |
| 1040 | } |
| 1041 | |
| 1042 | if (data->reset != 0) { |
| 1043 | if (ft_ctx != NULL) { |
| 1044 | ft_ctx->reset_tunnel_hit_counter = |
| 1045 | non_reset_tunnel_hit_counter; |
| 1046 | } else { |
| 1047 | p->reset.pkts = value.pkts; |
| 1048 | |
| 1049 | if (need_byte_count) |
| 1050 | p->reset.bytes = value.bytes; |
| 1051 | } |
no outgoing calls
no test coverage detected