]> git.proxmox.com Git - ceph.git/blob - ceph/src/msg/async/rdma/RDMAConnTCP.h
bump version to 12.0.3-pve3
[ceph.git] / ceph / src / msg / async / rdma / RDMAConnTCP.h
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) 2016 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 #ifndef CEPH_MSG_RDMA_CONNECTED_SOCKET_TCP_H
18 #define CEPH_MSG_RDMA_CONNECTED_SOCKET_TCP_H
19
20 #include "common/ceph_context.h"
21 #include "common/debug.h"
22 #include "common/errno.h"
23 #include "msg/async/Stack.h"
24 #include "Infiniband.h"
25 #include "RDMAConnectedSocketImpl.h"
26
27 class RDMAWorker;
28 class RDMADispatcher;
29
30 struct RDMAConnTCPInfo {
31 int sd;
32 };
33
34 class RDMAConnTCP : public RDMAConnMgr {
35 class C_handle_connection : public EventCallback {
36 RDMAConnTCP *cst;
37 bool active;
38 public:
39 C_handle_connection(RDMAConnTCP *w): cst(w), active(true) {};
40 void do_request(int fd) {
41 if (active)
42 cst->handle_connection();
43 };
44 void close() {
45 active = false;
46 };
47 };
48
49 IBSYNMsg peer_msg;
50 IBSYNMsg my_msg;
51 EventCallbackRef con_handler;
52 int tcp_fd = -1;
53
54 private:
55 void handle_connection();
56 int send_msg(CephContext *cct, int sd, IBSYNMsg& msg);
57 int recv_msg(CephContext *cct, int sd, IBSYNMsg& msg);
58 int activate();
59 void wire_gid_to_gid(const char *wgid, union ibv_gid *gid);
60 void gid_to_wire_gid(const union ibv_gid *gid, char wgid[]);
61
62 public:
63 RDMAConnTCP(CephContext *cct, RDMAConnectedSocketImpl *sock,
64 Infiniband* ib, RDMADispatcher* s, RDMAWorker *w,
65 void *info);
66 virtual ~RDMAConnTCP();
67
68 virtual ostream &print(ostream &out) const override;
69
70 void set_accept_fd(int sd);
71
72 virtual void cleanup() override;
73 virtual int try_connect(const entity_addr_t&, const SocketOptions &opt) override;
74 };
75
76 class RDMAServerConnTCP : public RDMAServerSocketImpl {
77 NetHandler net;
78 int server_setup_socket;
79
80 public:
81 RDMAServerConnTCP(CephContext *cct, Infiniband* i, RDMADispatcher *s, RDMAWorker *w, entity_addr_t& a);
82
83 int listen(entity_addr_t &sa, const SocketOptions &opt);
84 virtual int accept(ConnectedSocket *s, const SocketOptions &opts, entity_addr_t *out, Worker *w) override;
85 virtual void abort_accept() override;
86 virtual int fd() const override { return server_setup_socket; }
87 };
88
89 #endif