Motr  M0
lnet_ep.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 
33 static void nlx_ep_release(struct m0_ref *ref)
34 {
35  struct m0_net_end_point *ep;
36  struct nlx_xo_ep *xep;
37 
38  ep = container_of(ref, struct m0_net_end_point, nep_ref);
39  M0_PRE(m0_mutex_is_locked(&ep->nep_tm->ntm_mutex));
41  xep = container_of(ep, struct nlx_xo_ep, xe_ep);
42 
43  m0_nep_tlist_del(ep);
44  ep->nep_tm = NULL;
45  m0_free(xep);
46 }
47 
48 static int nlx_ep_create(struct m0_net_end_point **epp,
49  struct m0_net_transfer_mc *tm,
50  const struct nlx_core_ep_addr *cepa)
51 {
52  struct m0_net_end_point *ep;
53  struct m0_net_end_point *ep1;
54  struct nlx_xo_domain *dp;
55  struct nlx_xo_ep *xep;
56 
58  nlx_print_core_ep_addr("nlx_ep_create", cepa));
59  M0_PRE(m0_mutex_is_locked(&tm->ntm_mutex));
61  dp = tm->ntm_dom->nd_xprt_private;
62 
63  /* check if its already on the TM end point list */
64  m0_tl_for(m0_nep, &tm->ntm_end_points, ep1) {
66  xep = container_of(ep1, struct nlx_xo_ep, xe_ep);
67  if (nlx_core_ep_eq(&xep->xe_core, cepa)) {
69  *epp = ep1;
70  return 0;
71  }
72  } m0_tl_endfor;
73 
74  NLX_ALLOC_PTR(xep);
75  if (xep == NULL)
76  return M0_ERR(-ENOMEM);
78  xep->xe_core = *cepa;
79  nlx_core_ep_addr_encode(&dp->xd_core, cepa, xep->xe_addr);
80  ep = &xep->xe_ep;
81  m0_ref_init(&ep->nep_ref, 1, nlx_ep_release);
82  ep->nep_tm = tm;
83  m0_nep_tlink_init_at_tail(ep, &tm->ntm_end_points);
84  ep->nep_addr = &xep->xe_addr[0];
86  *epp = ep;
87  return 0;
88 }
89  /* LNetXODFS */
91 
92 /*
93  * Local variables:
94  * c-indentation-style: "K&R"
95  * c-basic-offset: 8
96  * tab-width: 8
97  * fill-column: 79
98  * scroll-step: 1
99  * End:
100  */
#define M0_PRE(cond)
struct m0_net_end_point xe_ep
Definition: lnet_xo.h:57
#define NULL
Definition: misc.h:38
#define NLXDBG(ptr, dbg, stmt)
Definition: lnet_main.c:877
uint64_t xe_magic
Definition: lnet_xo.h:54
char xe_addr[M0_NET_LNET_XEP_ADDR_LEN]
Definition: lnet_xo.h:66
struct m0_net_domain * ntm_dom
Definition: net.h:853
#define NLX_ALLOC_PTR(ptr)
Definition: lnet_core.h:638
#define container_of(ptr, type, member)
Definition: misc.h:33
struct m0_tl ntm_end_points
Definition: net.h:856
#define m0_tl_endfor
Definition: tlist.h:700
Definition: sock.c:754
void m0_ref_init(struct m0_ref *ref, int init_num, void(*release)(struct m0_ref *ref))
Definition: refs.c:24
return M0_ERR(-EOPNOTSUPP)
void * ntm_xprt_private
Definition: net.h:886
Definition: refs.h:34
void * nd_xprt_private
Definition: net.h:393
#define M0_ASSERT(cond)
M0_INTERNAL bool m0_mutex_is_locked(const struct m0_mutex *mutex)
Definition: mutex.c:95
struct nlx_core_domain xd_core
Definition: lnet_xo.h:77
static bool nlx_ep_invariant(const struct m0_net_end_point *ep)
static bool nlx_tm_invariant(const struct m0_net_transfer_mc *tm)
void nlx_core_ep_addr_encode(struct nlx_core_domain *lcdom, const struct nlx_core_ep_addr *cepa, char buf[M0_NET_LNET_XEP_ADDR_LEN])
Definition: lnet_core.c:427
#define M0_POST(cond)
M0_INTERNAL void m0_net_end_point_get(struct m0_net_end_point *ep)
Definition: ep.c:88
static int nlx_ep_create(struct m0_net_end_point **epp, struct m0_net_transfer_mc *tm, const struct nlx_core_ep_addr *cepa)
Definition: lnet_ep.c:48
static bool nlx_core_ep_eq(const struct nlx_core_ep_addr *cep1, const struct nlx_core_ep_addr *cep2)
Definition: lnet_core.h:537
char * ep
Definition: sw.h:132
static void nlx_ep_release(struct m0_ref *ref)
Definition: lnet_ep.c:33
struct nlx_core_ep_addr xe_core
Definition: lnet_xo.h:60
#define m0_tl_for(name, head, obj)
Definition: tlist.h:695
void m0_free(void *data)
Definition: memory.c:146