Blame src/vma/dev/time_converter.h

Packit 6d2c1b
/*
Packit 6d2c1b
 * Copyright (c) 2001-2020 Mellanox Technologies, Ltd. All rights reserved.
Packit 6d2c1b
 *
Packit 6d2c1b
 * This software is available to you under a choice of one of two
Packit 6d2c1b
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 6d2c1b
 * General Public License (GPL) Version 2, available from the file
Packit 6d2c1b
 * COPYING in the main directory of this source tree, or the
Packit 6d2c1b
 * BSD license below:
Packit 6d2c1b
 *
Packit 6d2c1b
 *     Redistribution and use in source and binary forms, with or
Packit 6d2c1b
 *     without modification, are permitted provided that the following
Packit 6d2c1b
 *     conditions are met:
Packit 6d2c1b
 *
Packit 6d2c1b
 *      - Redistributions of source code must retain the above
Packit 6d2c1b
 *        copyright notice, this list of conditions and the following
Packit 6d2c1b
 *        disclaimer.
Packit 6d2c1b
 *
Packit 6d2c1b
 *      - Redistributions in binary form must reproduce the above
Packit 6d2c1b
 *        copyright notice, this list of conditions and the following
Packit 6d2c1b
 *        disclaimer in the documentation and/or other materials
Packit 6d2c1b
 *        provided with the distribution.
Packit 6d2c1b
 *
Packit 6d2c1b
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 6d2c1b
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 6d2c1b
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 6d2c1b
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 6d2c1b
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 6d2c1b
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 6d2c1b
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 6d2c1b
 * SOFTWARE.
Packit 6d2c1b
 */
Packit 6d2c1b
Packit 6d2c1b
Packit 6d2c1b
#ifndef TIME_CONVERTER_H
Packit 6d2c1b
#define TIME_CONVERTER_H
Packit 6d2c1b
Packit 6d2c1b
#include <tr1/unordered_map>
Packit 6d2c1b
#include <infiniband/verbs.h>
Packit 6d2c1b
Packit 6d2c1b
#include "vma/util/sys_vars.h"
Packit 6d2c1b
#include "vma/sock/cleanable_obj.h"
Packit 6d2c1b
#include "vma/event/timer_handler.h"
Packit 6d2c1b
Packit 6d2c1b
class net_device_val;
Packit 6d2c1b
typedef std::tr1::unordered_map<int, net_device_val*> net_device_map_t;
Packit 6d2c1b
Packit 6d2c1b
class ctx_timestamping_params_t {
Packit 6d2c1b
public:
Packit 6d2c1b
Packit 6d2c1b
	uint64_t                hca_core_clock;
Packit 6d2c1b
	uint64_t                sync_hw_clock;
Packit 6d2c1b
	struct timespec         sync_systime;
Packit 6d2c1b
Packit 6d2c1b
	ctx_timestamping_params_t() : hca_core_clock(0), sync_hw_clock(0) {
Packit 6d2c1b
		sync_systime.tv_sec = 0;
Packit 6d2c1b
		sync_systime.tv_nsec = 0;
Packit 6d2c1b
	}
Packit 6d2c1b
};
Packit 6d2c1b
Packit 6d2c1b
class time_converter : public timer_handler, public cleanable_obj
Packit 6d2c1b
{
Packit 6d2c1b
public:
Packit 6d2c1b
	time_converter(): m_timer_handle(NULL), m_converter_status(TS_CONVERSION_MODE_DISABLE) {};
Packit 6d2c1b
	virtual ~time_converter() = 0;
Packit 6d2c1b
Packit 6d2c1b
	virtual void              convert_hw_time_to_system_time(uint64_t hwtime, struct timespec* systime) = 0;
Packit 6d2c1b
	virtual void              handle_timer_expired(void* user_data) = 0;
Packit 6d2c1b
	virtual void              clean_obj();
Packit 6d2c1b
	ts_conversion_mode_t      get_converter_status() { return m_converter_status; };
Packit 6d2c1b
Packit 6d2c1b
	static ts_conversion_mode_t update_device_converters_status(net_device_map_t& net_devices);
Packit 6d2c1b
Packit 6d2c1b
protected:
Packit 6d2c1b
	void*                     m_timer_handle;
Packit 6d2c1b
	ts_conversion_mode_t      m_converter_status;
Packit 6d2c1b
Packit 6d2c1b
	static uint32_t           get_single_converter_status(struct ibv_context* ctx);
Packit 6d2c1b
};
Packit 6d2c1b
Packit 6d2c1b
// pure virtual destructor implementation
Packit 6d2c1b
inline time_converter::~time_converter() { }
Packit 6d2c1b
Packit 6d2c1b
#endif //TIME_CONVERTER_H