ofproto/ofproto-dpif-xlate-cache.c
/* Push stats and perform side effects of flow translation. */
Push stats and perform side effects of flow translation.
Push stats and perform side effects of flow translation .
void
xlate_push_stats_entry(struct xc_entry *entry,
                       struct dpif_flow_stats *stats, bool offloaded)
{
    struct eth_addr dmac;
    switch (entry->type) {
    case XC_TABLE:
        ofproto_dpif_credit_table_stats(entry->table.ofproto,
                                        entry->table.id,
                                        entry->table.match
                                        ? stats->n_packets : 0,
                                        entry->table.match
                                        ? 0 : stats->n_packets);
        break;
    case XC_RULE:
        rule_dpif_credit_stats(entry->rule, stats, offloaded);
        break;
    case XC_BOND:
        bond_account(entry->bond.bond, entry->bond.flow,
                     entry->bond.vid, stats->n_bytes);
        break;
    case XC_NETDEV:
        xlate_cache_netdev(entry, stats);
        break;
    case XC_NETFLOW:
        netflow_flow_update(entry->nf.netflow, entry->nf.flow,
                            entry->nf.iface, stats);
        break;
    case XC_MIRROR:
        mirror_update_stats(entry->mirror.mbridge,
                            entry->mirror.mirrors,
                            stats->n_packets, stats->n_bytes);
        break;
    case XC_LEARN: {
        enum ofperr error;
        error = ofproto_flow_mod_learn(entry->learn.ofm, true,
                                       entry->learn.limit, NULL);
        if (error) {
            static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
            VLOG_WARN_RL(&rl, "xcache LEARN action execution failed.");
        }
        break;
    }
    case XC_NORMAL:
        xlate_mac_learning_update(entry->normal.ofproto,
                                  entry->normal.in_port,
                                  entry->normal.dl_src,
                                  entry->normal.vlan,
                                  entry->normal.is_gratuitous_arp);
        break;
    case XC_FIN_TIMEOUT:
        if (stats->tcp_flags & (TCP_FIN | TCP_RST)) {
            ofproto_rule_reduce_timeouts(&entry->fin.rule->up, entry->fin.idle,
                                         entry->fin.hard);
        }
        break;
    case XC_GROUP:
        group_dpif_credit_stats(entry->group.group, entry->group.bucket,
                                stats);
        break;
    case XC_TNL_NEIGH:
        tnl_neigh_lookup(entry->tnl_neigh_cache.br_name,
                         &entry->tnl_neigh_cache.d_ipv6, &dmac);
        break;
    case XC_TUNNEL_HEADER:
        if (entry->tunnel_hdr.operation == ADD) {
            stats->n_bytes += stats->n_packets * entry->tunnel_hdr.hdr_size;
        } else {
            stats->n_bytes -= stats->n_packets * entry->tunnel_hdr.hdr_size;
        }
        break;
    default:
        OVS_NOT_REACHED();
    }
}
void xlate_push_stats_entry ( struct xc_entry * entry , struct dpif_flow_stats * stats , bool offloaded ) { struct eth_addr dmac ; switch ( entry -> type ) { case XC_TABLE : ofproto_dpif_credit_table_stats ( entry -> table . ofproto , entry -> table . id , entry -> table . match ? stats -> n_packets : 0 , entry -> table . match ? 0 : stats -> n_packets ) ; break ; case XC_RULE : rule_dpif_credit_stats ( entry -> rule , stats , offloaded ) ; break ; case XC_BOND : bond_account ( entry -> bond . bond , entry -> bond . flow , entry -> bond . vid , stats -> n_bytes ) ; break ; case XC_NETDEV : xlate_cache_netdev ( entry , stats ) ; break ; case XC_NETFLOW : netflow_flow_update ( entry -> nf . netflow , entry -> nf . flow , entry -> nf . iface , stats ) ; break ; case XC_MIRROR : mirror_update_stats ( entry -> mirror . mbridge , entry -> mirror . mirrors , stats -> n_packets , stats -> n_bytes ) ; break ; case XC_LEARN : { enum ofperr error ; error = ofproto_flow_mod_learn ( entry -> learn . ofm , true , entry -> learn . limit , NULL ) ; if ( error ) { static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT ( 1 , 5 ) ; VLOG_WARN_RL ( & rl , " " ) ; } break ; } case XC_NORMAL : xlate_mac_learning_update ( entry -> normal . ofproto , entry -> normal . in_port , entry -> normal . dl_src , entry -> normal . vlan , entry -> normal . is_gratuitous_arp ) ; break ; case XC_FIN_TIMEOUT : if ( stats -> tcp_flags & ( TCP_FIN | TCP_RST ) ) { ofproto_rule_reduce_timeouts ( & entry -> fin . rule -> up , entry -> fin . idle , entry -> fin . hard ) ; } break ; case XC_GROUP : group_dpif_credit_stats ( entry -> group . group , entry -> group . bucket , stats ) ; break ; case XC_TNL_NEIGH : tnl_neigh_lookup ( entry -> tnl_neigh_cache . br_name , & entry -> tnl_neigh_cache . d_ipv6 , & dmac ) ; break ; case XC_TUNNEL_HEADER : if ( entry -> tunnel_hdr . operation == ADD ) { stats -> n_bytes += stats -> n_packets * entry -> tunnel_hdr . hdr_size ; } else { stats -> n_bytes -= stats -> n_packets * entry -> tunnel_hdr . hdr_size ; } break ; default : OVS_NOT_REACHED ( ) ; } }
Push stats and perform side effects of flow translation.
Push stats and perform side effects of flow translation .
/* Lookup neighbor to avoid timeout. */