| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/* |
| 3 |
* Copyright (C) 2017, Microsoft Corporation. |
| 4 |
* |
| 5 |
* Author(s): Long Li <[email protected]> |
| 6 |
*/ |
| 7 |
#ifndef _SMBDIRECT_H |
| 8 |
#define _SMBDIRECT_H |
| 9 |
|
| 10 |
#ifdef CONFIG_CIFS_SMB_DIRECT |
| 11 |
#define cifs_rdma_enabled(server) ((server)->rdma) |
| 12 |
|
| 13 |
#include "cifsglob.h" |
| 14 |
#include <rdma/ib_verbs.h> |
| 15 |
#include <rdma/rdma_cm.h> |
| 16 |
#include <linux/mempool.h> |
| 17 |
|
| 18 |
#include "../common/smbdirect/smbdirect.h" |
| 19 |
#include "../common/smbdirect/smbdirect_socket.h" |
| 20 |
|
| 21 |
extern int rdma_readwrite_threshold; |
| 22 |
extern int smbd_max_frmr_depth; |
| 23 |
extern int smbd_keep_alive_interval; |
| 24 |
extern int smbd_max_receive_size; |
| 25 |
extern int smbd_max_fragmented_recv_size; |
| 26 |
extern int smbd_max_send_size; |
| 27 |
extern int smbd_send_credit_target; |
| 28 |
extern int smbd_receive_credit_max; |
| 29 |
|
| 30 |
/* |
| 31 |
* The context for the SMBDirect transport |
| 32 |
* Everything related to the transport is here. It has several logical parts |
| 33 |
* 1. RDMA related structures |
| 34 |
* 2. SMBDirect connection parameters |
| 35 |
* 3. Memory registrations |
| 36 |
* 4. Receive and reassembly queues for data receive path |
| 37 |
* 5. mempools for allocating packets |
| 38 |
*/ |
| 39 |
struct smbd_connection { |
| 40 |
struct smbdirect_socket socket; |
| 41 |
}; |
| 42 |
|
| 43 |
/* Create a SMBDirect session */ |
| 44 |
struct smbd_connection *smbd_get_connection( |
| 45 |
struct TCP_Server_Info *server, struct sockaddr *dstaddr); |
| 46 |
|
| 47 |
const struct smbdirect_socket_parameters *smbd_get_parameters(struct smbd_connection *conn); |
| 48 |
|
| 49 |
/* Reconnect SMBDirect session */ |
| 50 |
int smbd_reconnect(struct TCP_Server_Info *server); |
| 51 |
/* Destroy SMBDirect session */ |
| 52 |
void smbd_destroy(struct TCP_Server_Info *server); |
| 53 |
|
| 54 |
/* Interface for carrying upper layer I/O through send/recv */ |
| 55 |
int smbd_recv(struct smbd_connection *info, struct msghdr *msg); |
| 56 |
int smbd_send(struct TCP_Server_Info *server, |
| 57 |
int num_rqst, struct smb_rqst *rqst); |
| 58 |
|
| 59 |
/* Interfaces to register and deregister MR for RDMA read/write */ |
| 60 |
struct smbdirect_mr_io *smbd_register_mr( |
| 61 |
struct smbd_connection *info, struct iov_iter *iter, |
| 62 |
bool writing, bool need_invalidate); |
| 63 |
void smbd_deregister_mr(struct smbdirect_mr_io *mr); |
| 64 |
|
| 65 |
#else |
| 66 |
#define cifs_rdma_enabled(server) 0 |
| 67 |
struct smbd_connection {}; |
| 68 |
static inline void *smbd_get_connection( |
| 69 |
struct TCP_Server_Info *server, struct sockaddr *dstaddr) {return NULL;} |
| 70 |
static inline int smbd_reconnect(struct TCP_Server_Info *server) {return -1; } |
| 71 |
static inline void smbd_destroy(struct TCP_Server_Info *server) {} |
| 72 |
static inline int smbd_recv(struct smbd_connection *info, struct msghdr *msg) {return -1; } |
| 73 |
static inline int smbd_send(struct TCP_Server_Info *server, int num_rqst, struct smb_rqst *rqst) {return -1; } |
| 74 |
#endif |
| 75 |
|
| 76 |
#endif |