Motr  M0
kbev_cqueue.c
Go to the documentation of this file.
1 /* -*- C -*- */
2 /*
3  * Copyright (c) 2012-2020 Seagate Technology LLC and/or its Affiliates
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * For any questions about this software or licensing,
18  * please email opensource@seagate.com or cortx-questions@seagate.com.
19  *
20  */
21 
22 
28 #include <linux/highmem.h> /* kmap_atomic */
29 
41  const struct nlx_core_bev_cqueue *q)
42 {
43  struct nlx_core_bev_link *p;
44  const struct nlx_core_kmem_loc *loc;
45  char *ptr;
46 
48  loc = &q->cbcq_producer_loc;
50 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
51  ptr = kmap_atomic(loc->kl_page);
52 #else
53  ptr = kmap_atomic(loc->kl_page, KM_USER1);
54 #endif
55  p = (struct nlx_core_bev_link *) (ptr + loc->kl_offset);
56  M0_POST(nlx_core_kmem_loc_invariant(&p->cbl_p_self_loc));
57  M0_POST(p->cbl_c_self != q->cbcq_consumer);
58  return p;
59 }
60 
69 static void bev_cqueue_put(struct nlx_core_bev_cqueue *q,
70  struct nlx_core_bev_link *p)
71 {
72 
74  M0_PRE(p->cbl_c_self != q->cbcq_consumer);
75  M0_PRE(nlx_core_kmem_loc_eq(&q->cbcq_producer_loc, &p->cbl_p_self_loc));
76  q->cbcq_producer_loc = p->cbl_p_next_loc;
77 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)
78  kunmap_atomic(p);
79 #else
80  kunmap_atomic(p, KM_USER1);
81 #endif
82  m0_atomic64_inc(&q->cbcq_count);
83 }
84 
92 static void bev_link_bless(struct nlx_core_bev_link *ql, struct page *pg)
93 {
95  pg, NLX_PAGE_OFFSET((unsigned long) ql));
96 }
97  /* bevcqueue */
99 
100 /*
101  * Local variables:
102  * c-indentation-style: "K&R"
103  * c-basic-offset: 8
104  * tab-width: 8
105  * fill-column: 80
106  * scroll-step: 1
107  * End:
108  */
static void m0_atomic64_inc(struct m0_atomic64 *a)
static void ptr(struct m0_addb2__context *ctx, const uint64_t *v, char *buf)
Definition: dump.c:440
static struct m0_addb2_philter p
Definition: consumer.c:40
#define M0_PRE(cond)
static struct m0_semaphore q
Definition: rwlock.c:55
#define NULL
Definition: misc.h:38
static void bev_cqueue_put(struct nlx_core_bev_cqueue *q, struct nlx_core_bev_link *p)
Definition: kbev_cqueue.c:69
struct page * kl_page
#define NLX_PAGE_OFFSET(addr)
Definition: klnet_core.h:404
static bool bev_cqueue_invariant(const struct nlx_core_bev_cqueue *q)
Definition: bev_cqueue.c:609
static bool nlx_core_kmem_loc_eq(const struct nlx_core_kmem_loc *a, const struct nlx_core_kmem_loc *b)
Definition: lnet_pvt.h:104
static struct nlx_core_bev_link * bev_cqueue_pnext(const struct nlx_core_bev_cqueue *q)
Definition: kbev_cqueue.c:40
#define M0_POST(cond)
static void nlx_core_kmem_loc_set(struct nlx_core_kmem_loc *loc, struct page *pg, uint32_t off)
Definition: klnet_core.c:1127
static void bev_link_bless(struct nlx_core_bev_link *ql, struct page *pg)
Definition: kbev_cqueue.c:92
#define _0C(exp)
Definition: assert.h:311
static bool nlx_core_kmem_loc_invariant(const struct nlx_core_kmem_loc *loc)
Definition: lnet_pvt.h:81