1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2015 XSky <haomai@xsky.com>
8 * Author: Haomai Wang <haomaiwang@gmail.com>
10 * This is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License version 2.1, as published by the Free Software
13 * Foundation. See file COPYING.
17 #include "common/errno.h"
18 #include "DPDKStack.h"
19 #include "EventDPDK.h"
21 #include "common/dout.h"
22 #include "include/assert.h"
24 #define dout_subsys ceph_subsys_ms
27 #define dout_prefix *_dout << "DPDKDriver."
29 int DPDKDriver::init(EventCenter *c, int nevent)
34 int DPDKDriver::add_event(int fd, int cur_mask, int add_mask)
36 ldout(cct, 20) << __func__ << " add event fd=" << fd << " cur_mask=" << cur_mask
37 << " add_mask=" << add_mask << dendl;
39 int r = manager.listen(fd, add_mask);
41 lderr(cct) << __func__ << " add fd=" << fd << " failed. "
42 << cpp_strerror(-r) << dendl;
49 int DPDKDriver::del_event(int fd, int cur_mask, int delmask)
51 ldout(cct, 20) << __func__ << " del event fd=" << fd << " cur_mask=" << cur_mask
52 << " delmask=" << delmask << dendl;
55 if (delmask != EVENT_NONE) {
56 if ((r = manager.unlisten(fd, delmask)) < 0) {
57 lderr(cct) << __func__ << " delete fd=" << fd << " delmask=" << delmask
58 << " failed." << cpp_strerror(-r) << dendl;
65 int DPDKDriver::resize_events(int newsize)
70 int DPDKDriver::event_wait(vector<FiredFileEvent> &fired_events, struct timeval *tvp)
73 int events[num_events];
74 int masks[num_events];
76 int retval = manager.poll(events, masks, num_events, tvp);
78 fired_events.resize(retval);
79 for (int i = 0; i < retval; i++) {
80 fired_events[i].fd = events[i];
81 fired_events[i].mask = masks[i];