RDS: IB: add mr reused stats
[deliverable/linux.git] / net / rds / ib_mr.h
CommitLineData
f6df683f 1/*
2 * Copyright (c) 2016 Oracle. All rights reserved.
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32#ifndef _RDS_IB_MR_H
33#define _RDS_IB_MR_H
34
35#include <linux/kernel.h>
36
37#include "rds.h"
38#include "ib.h"
39
40#define RDS_MR_1M_POOL_SIZE (8192 / 2)
41#define RDS_MR_1M_MSG_SIZE 256
42#define RDS_MR_8K_MSG_SIZE 2
43#define RDS_MR_8K_SCALE (256 / (RDS_MR_8K_MSG_SIZE + 1))
44#define RDS_MR_8K_POOL_SIZE (RDS_MR_8K_SCALE * (8192 / 2))
45
a69365a3 46struct rds_ib_fmr {
47 struct ib_fmr *fmr;
48 u64 *dma;
49};
50
f6df683f 51/* This is stored as mr->r_trans_private. */
52struct rds_ib_mr {
d4de76da 53 struct rds_ib_device *device;
54 struct rds_ib_mr_pool *pool;
55 struct rds_ib_connection *ic;
f6df683f 56
d4de76da 57 struct llist_node llnode;
f6df683f 58
59 /* unmap_list is for freeing */
d4de76da 60 struct list_head unmap_list;
61 unsigned int remap_count;
f6df683f 62
d4de76da 63 struct scatterlist *sg;
64 unsigned int sg_len;
65 int sg_dma_len;
a69365a3 66
67 union {
68 struct rds_ib_fmr fmr;
69 } u;
f6df683f 70};
71
72/* Our own little MR pool */
73struct rds_ib_mr_pool {
74 unsigned int pool_type;
75 struct mutex flush_lock; /* serialize fmr invalidate */
76 struct delayed_work flush_worker; /* flush worker */
77
78 atomic_t item_count; /* total # of MRs */
79 atomic_t dirty_count; /* # dirty of MRs */
80
81 struct llist_head drop_list; /* MRs not reached max_maps */
82 struct llist_head free_list; /* unused MRs */
83 struct llist_head clean_list; /* unused & unmapped MRs */
84 wait_queue_head_t flush_wait;
85
86 atomic_t free_pinned; /* memory pinned by free MRs */
87 unsigned long max_items;
88 unsigned long max_items_soft;
89 unsigned long max_free_pinned;
90 struct ib_fmr_attr fmr_attr;
91};
92
93extern struct workqueue_struct *rds_ib_mr_wq;
94extern unsigned int rds_ib_mr_1m_pool_size;
95extern unsigned int rds_ib_mr_8k_pool_size;
96
97struct rds_ib_mr_pool *rds_ib_create_mr_pool(struct rds_ib_device *rds_dev,
98 int npages);
99void rds_ib_get_mr_info(struct rds_ib_device *rds_ibdev,
100 struct rds_info_rdma_connection *iinfo);
101void rds_ib_destroy_mr_pool(struct rds_ib_mr_pool *);
102void *rds_ib_get_mr(struct scatterlist *sg, unsigned long nents,
103 struct rds_sock *rs, u32 *key_ret);
104void rds_ib_sync_mr(void *trans_private, int dir);
105void rds_ib_free_mr(void *trans_private, int invalidate);
106void rds_ib_flush_mrs(void);
107int rds_ib_mr_init(void);
108void rds_ib_mr_exit(void);
109
110void __rds_ib_teardown_mr(struct rds_ib_mr *);
111void rds_ib_teardown_mr(struct rds_ib_mr *);
112struct rds_ib_mr *rds_ib_alloc_fmr(struct rds_ib_device *, int);
113int rds_ib_map_fmr(struct rds_ib_device *, struct rds_ib_mr *,
114 struct scatterlist *, unsigned int);
115struct rds_ib_mr *rds_ib_reuse_mr(struct rds_ib_mr_pool *);
116int rds_ib_flush_mr_pool(struct rds_ib_mr_pool *, int, struct rds_ib_mr **);
490ea596 117struct rds_ib_mr *rds_ib_reg_fmr(struct rds_ib_device *, struct scatterlist *,
118 unsigned long, u32 *);
119struct rds_ib_mr *rds_ib_try_reuse_ibmr(struct rds_ib_mr_pool *);
120void rds_ib_unreg_fmr(struct list_head *, unsigned int *,
121 unsigned long *, unsigned int);
122void rds_ib_free_fmr_list(struct rds_ib_mr *);
f6df683f 123#endif
This page took 0.033732 seconds and 5 git commands to generate.