-static uint64_t
-nxm_read_field(const struct nxm_field *src, const struct flow *flow)
-{
- switch (src->index) {
- case NFI_NXM_OF_IN_PORT:
- return flow->in_port;
-
- case NFI_NXM_OF_ETH_DST:
- return eth_addr_to_uint64(flow->dl_dst);
-
- case NFI_NXM_OF_ETH_SRC:
- return eth_addr_to_uint64(flow->dl_src);
-
- case NFI_NXM_OF_ETH_TYPE:
- return ntohs(ofputil_dl_type_to_openflow(flow->dl_type));
-
- case NFI_NXM_OF_VLAN_TCI:
- return ntohs(flow->vlan_tci);
-
- case NFI_NXM_OF_IP_TOS:
- return flow->nw_tos & IP_DSCP_MASK;
-
- case NFI_NXM_NX_IP_ECN:
- return flow->nw_tos & IP_ECN_MASK;
-
- case NFI_NXM_NX_IP_TTL:
- return flow->nw_ttl;
-
- case NFI_NXM_NX_IP_FRAG:
- return flow->nw_frag;
-
- case NFI_NXM_OF_IP_PROTO:
- case NFI_NXM_OF_ARP_OP:
- return flow->nw_proto;
-
- case NFI_NXM_OF_IP_SRC:
- case NFI_NXM_OF_ARP_SPA:
- return ntohl(flow->nw_src);
-
- case NFI_NXM_OF_IP_DST:
- case NFI_NXM_OF_ARP_TPA:
- return ntohl(flow->nw_dst);
-
- case NFI_NXM_OF_TCP_SRC:
- case NFI_NXM_OF_UDP_SRC:
- return ntohs(flow->tp_src);
-
- case NFI_NXM_OF_TCP_DST:
- case NFI_NXM_OF_UDP_DST:
- return ntohs(flow->tp_dst);
-
- case NFI_NXM_OF_ICMP_TYPE:
- case NFI_NXM_NX_ICMPV6_TYPE:
- return ntohs(flow->tp_src) & 0xff;
-
- case NFI_NXM_OF_ICMP_CODE:
- case NFI_NXM_NX_ICMPV6_CODE:
- return ntohs(flow->tp_dst) & 0xff;
-
- case NFI_NXM_NX_TUN_ID:
- return ntohll(flow->tun_id);
-
- case NFI_NXM_NX_IPV6_LABEL:
- return ntohl(flow->ipv6_label);
-
-#define NXM_READ_REGISTER(IDX) \
- case NFI_NXM_NX_REG##IDX: \
- return flow->regs[IDX]; \
- case NFI_NXM_NX_REG##IDX##_W: \
- NOT_REACHED();
-
- NXM_READ_REGISTER(0);
-#if FLOW_N_REGS >= 2
- NXM_READ_REGISTER(1);
-#endif
-#if FLOW_N_REGS >= 3
- NXM_READ_REGISTER(2);
-#endif
-#if FLOW_N_REGS >= 4
- NXM_READ_REGISTER(3);
-#endif
-#if FLOW_N_REGS >= 5
- NXM_READ_REGISTER(4);
-#endif
-#if FLOW_N_REGS > 5
-#error
-#endif
-
- case NFI_NXM_NX_ARP_SHA:
- case NFI_NXM_NX_ND_SLL:
- return eth_addr_to_uint64(flow->arp_sha);
-
- case NFI_NXM_NX_ARP_THA:
- case NFI_NXM_NX_ND_TLL:
- return eth_addr_to_uint64(flow->arp_tha);
-
- case NFI_NXM_NX_TUN_ID_W:
- case NFI_NXM_OF_ETH_DST_W:
- case NFI_NXM_OF_VLAN_TCI_W:
- case NFI_NXM_OF_IP_SRC_W:
- case NFI_NXM_OF_IP_DST_W:
- case NFI_NXM_OF_ARP_SPA_W:
- case NFI_NXM_OF_ARP_TPA_W:
- case NFI_NXM_NX_IPV6_SRC:
- case NFI_NXM_NX_IPV6_SRC_W:
- case NFI_NXM_NX_IPV6_DST:
- case NFI_NXM_NX_IPV6_DST_W:
- case NFI_NXM_NX_IP_FRAG_W:
- case NFI_NXM_NX_ND_TARGET:
- case N_NXM_FIELDS:
- NOT_REACHED();
- }
-
- NOT_REACHED();