Blame src/vma/dev/ring_eth_direct.h

Packit Service aa3af4
/*
Packit Service aa3af4
 * Copyright (c) 2001-2020 Mellanox Technologies, Ltd. All rights reserved.
Packit Service aa3af4
 *
Packit Service aa3af4
 * This software is available to you under a choice of one of two
Packit Service aa3af4
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit Service aa3af4
 * General Public License (GPL) Version 2, available from the file
Packit Service aa3af4
 * COPYING in the main directory of this source tree, or the
Packit Service aa3af4
 * BSD license below:
Packit Service aa3af4
 *
Packit Service aa3af4
 *     Redistribution and use in source and binary forms, with or
Packit Service aa3af4
 *     without modification, are permitted provided that the following
Packit Service aa3af4
 *     conditions are met:
Packit Service aa3af4
 *
Packit Service aa3af4
 *      - Redistributions of source code must retain the above
Packit Service aa3af4
 *        copyright notice, this list of conditions and the following
Packit Service aa3af4
 *        disclaimer.
Packit Service aa3af4
 *
Packit Service aa3af4
 *      - Redistributions in binary form must reproduce the above
Packit Service aa3af4
 *        copyright notice, this list of conditions and the following
Packit Service aa3af4
 *        disclaimer in the documentation and/or other materials
Packit Service aa3af4
 *        provided with the distribution.
Packit Service aa3af4
 *
Packit Service aa3af4
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit Service aa3af4
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit Service aa3af4
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit Service aa3af4
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit Service aa3af4
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit Service aa3af4
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit Service aa3af4
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit Service aa3af4
 * SOFTWARE.
Packit Service aa3af4
 */
Packit Service aa3af4
Packit Service aa3af4
#ifndef SRC_VMA_DEV_RING_ETH_DIRECT_H_
Packit Service aa3af4
#define SRC_VMA_DEV_RING_ETH_DIRECT_H_
Packit Service aa3af4
Packit Service aa3af4
#include <tr1/unordered_map>
Packit Service aa3af4
#include "dev/ring_simple.h"
Packit Service aa3af4
Packit Service aa3af4
Packit Service aa3af4
typedef std::pair<void*, size_t> pair_void_size_t;
Packit Service aa3af4
typedef std::pair<uint32_t, int> pair_mr_ref_t;
Packit Service aa3af4
namespace std { namespace tr1 {
Packit Service aa3af4
template<>
Packit Service aa3af4
class hash<pair_void_size_t>
Packit Service aa3af4
{
Packit Service aa3af4
public:
Packit Service aa3af4
	size_t operator()(const pair_void_size_t &key) const
Packit Service aa3af4
	{
Packit Service aa3af4
		hash<size_t>_hash;
Packit Service aa3af4
		return _hash((uint64_t)key.first ^ key.second);
Packit Service aa3af4
	}
Packit Service aa3af4
};
Packit Service aa3af4
}}
Packit Service aa3af4
Packit Service aa3af4
typedef std::tr1::unordered_map<pair_void_size_t, pair_mr_ref_t> addr_len_mr_map_t;
Packit Service aa3af4
Packit Service aa3af4
class ring_eth_direct : public ring_eth
Packit Service aa3af4
{
Packit Service aa3af4
public:
Packit Service aa3af4
	ring_eth_direct(int if_index,
Packit Service aa3af4
		    vma_external_mem_attr *ext_ring_attr, ring *parent = NULL);
Packit Service aa3af4
	virtual		~ring_eth_direct();
Packit Service aa3af4
	virtual qp_mgr*	create_qp_mgr(const ib_ctx_handler* ib_ctx,
Packit Service aa3af4
					      uint8_t port_num,
Packit Service aa3af4
					      struct ibv_comp_channel* p_rx_comp_event_channel);
Packit Service aa3af4
	// memory handler
Packit Service aa3af4
	virtual int	reg_mr(void *addr, size_t length, uint32_t &lkey);
Packit Service aa3af4
	virtual int	dereg_mr(void *addr, size_t length);
Packit Service aa3af4
	// dummy functions to block memory usage and internal thread
Packit Service aa3af4
	virtual void	init_tx_buffers(uint32_t count);
Packit Service aa3af4
	virtual mem_buf_desc_t* mem_buf_tx_get(ring_user_id_t id, bool b_block, int n_num_mem_bufs = 1);
Packit Service aa3af4
	virtual int	drain_and_proccess(cq_type_t cq_type);
Packit Service aa3af4
	virtual int	poll_and_process_element_rx(uint64_t* p_cq_poll_sn,
Packit Service aa3af4
					void* pv_fd_ready_array);
Packit Service aa3af4
private:
Packit Service aa3af4
	vma_external_mem_attr	m_ring_attr;
Packit Service aa3af4
	addr_len_mr_map_t	m_mr_map;
Packit Service aa3af4
};
Packit Service aa3af4
Packit Service aa3af4
Packit Service aa3af4
#endif /* SRC_VMA_DEV_RING_ETH_DIRECT_H_ */