void rfs_uc::prepare_flow_spec() { transport_type_t type = m_p_ring->get_transport_type(); ring_resources_map_t::iterator ring_resource_iter = m_p_ring->m_ring_resources_map.begin(); for (; ring_resource_iter != m_p_ring->m_ring_resources_map.end(); ring_resource_iter++) { attach_flow_data_t* p_attach_flow_data = NULL; attach_flow_data_ib_ipv4_tcp_udp_t* attach_flow_data_ib = NULL; attach_flow_data_eth_ipv4_tcp_udp_t* attach_flow_data_eth = NULL; vma_ibv_flow_spec_ipv4* p_ipv4 = NULL; vma_ibv_flow_spec_tcp_udp* p_tcp_udp = NULL; switch (type) { case VMA_TRANSPORT_IB: attach_flow_data_ib = new attach_flow_data_ib_ipv4_tcp_udp_t(ring_resource_iter->second.m_p_qp_mgr); #ifdef DEFINED_IBV_FLOW_SPEC_IB ibv_flow_spec_ib_set_by_dst_qpn(&(attach_flow_data_ib->ibv_flow_attr.ib), htonl(((IPoIB_addr*)ring_resource_iter->first.get_l2_addr())->get_qpn())); #endif p_ipv4 = &(attach_flow_data_ib->ibv_flow_attr.ipv4); p_tcp_udp = &(attach_flow_data_ib->ibv_flow_attr.tcp_udp); p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_ib; break; case VMA_TRANSPORT_ETH: attach_flow_data_eth = new attach_flow_data_eth_ipv4_tcp_udp_t(ring_resource_iter->second.m_p_qp_mgr); ibv_flow_spec_eth_set(&(attach_flow_data_eth->ibv_flow_attr.eth), ring_resource_iter->first.get_l2_addr()->get_address(), htons(ring_resource_iter->second.m_p_qp_mgr->get_partiton())); p_ipv4 = &(attach_flow_data_eth->ibv_flow_attr.ipv4); p_tcp_udp = &(attach_flow_data_eth->ibv_flow_attr.tcp_udp); p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_eth; break; BULLSEYE_EXCLUDE_BLOCK_START default: rfs_logpanic("Incompatible transport type = %d", type); break; BULLSEYE_EXCLUDE_BLOCK_END } ibv_flow_spec_ipv4_set(p_ipv4, m_flow_tuple.get_dst_ip(), m_flow_tuple.get_src_ip()); ibv_flow_spec_tcp_udp_set(p_tcp_udp, (m_flow_tuple.get_protocol() == PROTO_TCP), m_flow_tuple.get_dst_port(), m_flow_tuple.get_src_port()); m_attach_flow_data_vector.push_back(p_attach_flow_data); } }
void rfs_uc::prepare_flow_spec() { transport_type_t type = m_p_ring->get_transport_type(); /* * todo note that ring is not locked here. * we touch members that should not change during the ring life. * the ring will not be deleted as we increased refcnt. * if one of these assumptions change, we must lock. */ ring_resources_map_t::iterator ring_resource_iter = m_p_ring->m_ring_resources_map.begin(); for (; ring_resource_iter != m_p_ring->m_ring_resources_map.end(); ring_resource_iter++) { attach_flow_data_t* p_attach_flow_data = NULL; attach_flow_data_ib_ipv4_tcp_udp_t* attach_flow_data_ib = NULL; attach_flow_data_eth_ipv4_tcp_udp_t* attach_flow_data_eth = NULL; vma_ibv_flow_spec_ipv4* p_ipv4 = NULL; vma_ibv_flow_spec_tcp_udp* p_tcp_udp = NULL; switch (type) { case VMA_TRANSPORT_IB: attach_flow_data_ib = new attach_flow_data_ib_ipv4_tcp_udp_t(ring_resource_iter->second.m_p_qp_mgr); #ifdef DEFINED_IBV_FLOW_SPEC_IB ibv_flow_spec_ib_set_by_dst_qpn(&(attach_flow_data_ib->ibv_flow_attr.ib), htonl(((IPoIB_addr*)ring_resource_iter->first.get_l2_addr())->get_qpn())); #endif p_ipv4 = &(attach_flow_data_ib->ibv_flow_attr.ipv4); p_tcp_udp = &(attach_flow_data_ib->ibv_flow_attr.tcp_udp); p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_ib; break; case VMA_TRANSPORT_ETH: attach_flow_data_eth = new attach_flow_data_eth_ipv4_tcp_udp_t(ring_resource_iter->second.m_p_qp_mgr); ibv_flow_spec_eth_set(&(attach_flow_data_eth->ibv_flow_attr.eth), ring_resource_iter->first.get_l2_addr()->get_address(), htons(ring_resource_iter->second.m_p_qp_mgr->get_partiton())); p_ipv4 = &(attach_flow_data_eth->ibv_flow_attr.ipv4); p_tcp_udp = &(attach_flow_data_eth->ibv_flow_attr.tcp_udp); p_attach_flow_data = (attach_flow_data_t*)attach_flow_data_eth; break; BULLSEYE_EXCLUDE_BLOCK_START default: rfs_logpanic("Incompatible transport type = %d", type); break; BULLSEYE_EXCLUDE_BLOCK_END } ibv_flow_spec_ipv4_set(p_ipv4, m_flow_tuple.get_dst_ip(), m_flow_tuple.get_src_ip()); ibv_flow_spec_tcp_udp_set(p_tcp_udp, (m_flow_tuple.get_protocol() == PROTO_TCP), m_flow_tuple.get_dst_port(), m_flow_tuple.get_src_port()); if (m_flow_tuple.get_src_port() || m_flow_tuple.get_src_ip()) { // set priority of 5-tuple to be higher than 3-tuple // to make sure 5-tuple have higher priority on ConnectX-4 p_attach_flow_data->ibv_flow_attr.priority = 0; } m_attach_flow_data_vector.push_back(p_attach_flow_data); } }