]> git.proxmox.com Git - ceph.git/blob - ceph/src/msg/async/dpdk/EventDPDK.cc
import quincy beta 17.1.0
[ceph.git] / ceph / src / msg / async / dpdk / EventDPDK.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3 /*
4 * Ceph - scalable distributed file system
5 *
6 * Copyright (C) 2015 XSky <haomai@xsky.com>
7 *
8 * Author: Haomai Wang <haomaiwang@gmail.com>
9 *
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.
14 *
15 */
16
17 #include "common/errno.h"
18 #include "DPDKStack.h"
19 #include "EventDPDK.h"
20
21 #include "common/dout.h"
22 #include "include/ceph_assert.h"
23
24 #define dout_subsys ceph_subsys_ms
25
26 #undef dout_prefix
27 #define dout_prefix *_dout << "DPDKDriver."
28
29 int DPDKDriver::init(EventCenter *c, int nevent)
30 {
31 return 0;
32 }
33
34 int DPDKDriver::add_event(int fd, int cur_mask, int add_mask)
35 {
36 ldout(cct, 20) << __func__ << " add event fd=" << fd << " cur_mask=" << cur_mask
37 << " add_mask=" << add_mask << dendl;
38
39 int r = manager.listen(fd, add_mask);
40 if (r < 0) {
41 lderr(cct) << __func__ << " add fd=" << fd << " failed. "
42 << cpp_strerror(-r) << dendl;
43 return -errno;
44 }
45
46 return 0;
47 }
48
49 int DPDKDriver::del_event(int fd, int cur_mask, int delmask)
50 {
51 ldout(cct, 20) << __func__ << " del event fd=" << fd << " cur_mask=" << cur_mask
52 << " delmask=" << delmask << dendl;
53 int r = 0;
54
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;
59 return r;
60 }
61 }
62 return 0;
63 }
64
65 int DPDKDriver::resize_events(int newsize)
66 {
67 return 0;
68 }
69
70 int DPDKDriver::event_wait(std::vector<FiredFileEvent> &fired_events, struct timeval *tvp)
71 {
72 int num_events = 512;
73 int events[num_events];
74 int masks[num_events];
75
76 int retval = manager.poll(events, masks, num_events, tvp);
77 if (retval > 0) {
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];
82 }
83 }
84 return retval;
85 }