Lines Matching +full:phy +full:- +full:s

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson AB 2010
7 #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__
83 this->mux = cfmuxl_create(); in cfcnfg_create()
84 if (!this->mux) in cfcnfg_create()
86 this->ctrl = cfctrl_create(); in cfcnfg_create()
87 if (!this->ctrl) in cfcnfg_create()
90 resp = cfctrl_get_respfuncs(this->ctrl); in cfcnfg_create()
91 resp->enum_rsp = cfctrl_enum_resp; in cfcnfg_create()
92 resp->linkerror_ind = cfctrl_resp_func; in cfcnfg_create()
93 resp->linkdestroy_rsp = cfcnfg_linkdestroy_rsp; in cfcnfg_create()
94 resp->sleep_rsp = cfctrl_resp_func; in cfcnfg_create()
95 resp->wake_rsp = cfctrl_resp_func; in cfcnfg_create()
96 resp->restart_rsp = cfctrl_resp_func; in cfcnfg_create()
97 resp->radioset_rsp = cfctrl_resp_func; in cfcnfg_create()
98 resp->linksetup_rsp = cfcnfg_linkup_rsp; in cfcnfg_create()
99 resp->reject_rsp = cfcnfg_reject_rsp; in cfcnfg_create()
100 INIT_LIST_HEAD(&this->phys); in cfcnfg_create()
102 cfmuxl_set_uplayer(this->mux, this->ctrl, 0); in cfcnfg_create()
103 layer_set_dn(this->ctrl, this->mux); in cfcnfg_create()
104 layer_set_up(this->ctrl, this); in cfcnfg_create()
105 mutex_init(&this->lock); in cfcnfg_create()
111 kfree(this->mux); in cfcnfg_create()
112 kfree(this->ctrl); in cfcnfg_create()
123 kfree(cfg->mux); in cfcnfg_remove()
124 cfctrl_remove(cfg->ctrl); in cfcnfg_remove()
136 struct cfcnfg_phyinfo *phy; in cfcnfg_get_phyinfo_rcu() local
138 list_for_each_entry_rcu(phy, &cnfg->phys, node) in cfcnfg_get_phyinfo_rcu()
139 if (phy->id == phyid) in cfcnfg_get_phyinfo_rcu()
140 return phy; in cfcnfg_get_phyinfo_rcu()
152 struct cfcnfg_phyinfo *phy; in cfcnfg_get_phyid() local
154 list_for_each_entry_rcu(phy, &cnfg->phys, node) { in cfcnfg_get_phyid()
155 if (phy->up && phy->pref == phy_pref && in cfcnfg_get_phyid()
156 phy->frm_layer != NULL) in cfcnfg_get_phyid()
158 return &phy->dev_info; in cfcnfg_get_phyid()
162 list_for_each_entry_rcu(phy, &cnfg->phys, node) in cfcnfg_get_phyid()
163 if (phy->up) in cfcnfg_get_phyid()
164 return &phy->dev_info; in cfcnfg_get_phyid()
171 struct cfcnfg_phyinfo *phy; in cfcnfg_get_id_from_ifi() local
173 list_for_each_entry_rcu(phy, &cnfg->phys, node) in cfcnfg_get_id_from_ifi()
174 if (phy->ifindex == ifi && phy->up) in cfcnfg_get_id_from_ifi()
175 return phy->id; in cfcnfg_get_id_from_ifi()
176 return -ENODEV; in cfcnfg_get_id_from_ifi()
185 cfctrl_cancel_req(cfg->ctrl, adap_layer); in caif_disconnect_client()
186 channel_id = adap_layer->id; in caif_disconnect_client()
189 servl = cfmuxl_remove_uplayer(cfg->mux, channel_id); in caif_disconnect_client()
190 cfctrl_linkdown_req(cfg->ctrl, channel_id, adap_layer); in caif_disconnect_client()
198 if (adap_layer->ctrlcmd != NULL) in caif_disconnect_client()
199 adap_layer->ctrlcmd(adap_layer, CAIF_CTRLCMD_DEINIT_RSP, 0); in caif_disconnect_client()
219 struct caif_connect_request *s, in caif_connect_req_to_link_param() argument
228 l->priority = CAIF_PRIO_MAX - s->priority + 1; in caif_connect_req_to_link_param()
230 if (s->ifindex != 0) { in caif_connect_req_to_link_param()
231 res = cfcnfg_get_id_from_ifi(cnfg, s->ifindex); in caif_connect_req_to_link_param()
234 l->phyid = res; in caif_connect_req_to_link_param()
236 switch (s->link_selector) { in caif_connect_req_to_link_param()
244 return -EINVAL; in caif_connect_req_to_link_param()
248 return -ENODEV; in caif_connect_req_to_link_param()
249 l->phyid = dev_info->id; in caif_connect_req_to_link_param()
251 switch (s->protocol) { in caif_connect_req_to_link_param()
253 l->linktype = CFCTRL_SRV_VEI; in caif_connect_req_to_link_param()
254 l->endpoint = (s->sockaddr.u.at.type >> 2) & 0x3; in caif_connect_req_to_link_param()
255 l->chtype = s->sockaddr.u.at.type & 0x3; in caif_connect_req_to_link_param()
258 l->linktype = CFCTRL_SRV_DATAGRAM; in caif_connect_req_to_link_param()
259 l->chtype = 0x00; in caif_connect_req_to_link_param()
260 l->u.datagram.connid = s->sockaddr.u.dgm.connection_id; in caif_connect_req_to_link_param()
263 l->linktype = CFCTRL_SRV_DATAGRAM; in caif_connect_req_to_link_param()
264 l->chtype = 0x03; in caif_connect_req_to_link_param()
265 l->endpoint = 0x00; in caif_connect_req_to_link_param()
266 l->u.datagram.connid = s->sockaddr.u.dgm.connection_id; in caif_connect_req_to_link_param()
269 l->linktype = CFCTRL_SRV_RFM; in caif_connect_req_to_link_param()
270 l->u.datagram.connid = s->sockaddr.u.rfm.connection_id; in caif_connect_req_to_link_param()
271 strscpy(l->u.rfm.volume, s->sockaddr.u.rfm.volume, in caif_connect_req_to_link_param()
272 sizeof(l->u.rfm.volume)); in caif_connect_req_to_link_param()
275 l->linktype = CFCTRL_SRV_UTIL; in caif_connect_req_to_link_param()
276 l->endpoint = 0x00; in caif_connect_req_to_link_param()
277 l->chtype = 0x00; in caif_connect_req_to_link_param()
278 strscpy(l->u.utility.name, s->sockaddr.u.util.service, in caif_connect_req_to_link_param()
279 sizeof(l->u.utility.name)); in caif_connect_req_to_link_param()
280 caif_assert(sizeof(l->u.utility.name) > 10); in caif_connect_req_to_link_param()
281 l->u.utility.paramlen = s->param.size; in caif_connect_req_to_link_param()
282 if (l->u.utility.paramlen > sizeof(l->u.utility.params)) in caif_connect_req_to_link_param()
283 l->u.utility.paramlen = sizeof(l->u.utility.params); in caif_connect_req_to_link_param()
285 memcpy(l->u.utility.params, s->param.data, in caif_connect_req_to_link_param()
286 l->u.utility.paramlen); in caif_connect_req_to_link_param()
290 l->linktype = CFCTRL_SRV_DBG; in caif_connect_req_to_link_param()
291 l->endpoint = s->sockaddr.u.dbg.service; in caif_connect_req_to_link_param()
292 l->chtype = s->sockaddr.u.dbg.type; in caif_connect_req_to_link_param()
295 return -EINVAL; in caif_connect_req_to_link_param()
305 struct cfcnfg_phyinfo *phy; in caif_connect_client() local
315 phy = cfcnfg_get_phyinfo_rcu(cfg, param.phyid); in caif_connect_client()
316 if (!phy) { in caif_connect_client()
317 err = -ENODEV; in caif_connect_client()
320 err = -EINVAL; in caif_connect_client()
326 if (adap_layer->receive == NULL) { in caif_connect_client()
327 pr_err("adap_layer->receive is NULL\n"); in caif_connect_client()
330 if (adap_layer->ctrlcmd == NULL) { in caif_connect_client()
331 pr_err("adap_layer->ctrlcmd == NULL\n"); in caif_connect_client()
335 err = -ENODEV; in caif_connect_client()
336 frml = phy->frm_layer; in caif_connect_client()
338 pr_err("Specified PHY type does not exist!\n"); in caif_connect_client()
341 caif_assert(param.phyid == phy->id); in caif_connect_client()
342 caif_assert(phy->frm_layer->id == in caif_connect_client()
344 caif_assert(phy->phy_layer->id == in caif_connect_client()
347 *ifindex = phy->ifindex; in caif_connect_client()
349 *proto_head = protohead[param.linktype] + phy->head_room; in caif_connect_client()
354 cfctrl_enum_req(cfg->ctrl, param.phyid); in caif_connect_client()
355 return cfctrl_linkup_request(cfg->ctrl, &param, adap_layer); in caif_connect_client()
366 if (adapt_layer != NULL && adapt_layer->ctrlcmd != NULL) in cfcnfg_reject_rsp()
367 adapt_layer->ctrlcmd(adapt_layer, in cfcnfg_reject_rsp()
382 if (adapt_layer != NULL && adapt_layer->ctrlcmd != NULL) in cfcnfg_linkup_rsp()
383 adapt_layer->ctrlcmd(adapt_layer, in cfcnfg_linkup_rsp()
392 cfctrl_linkdown_req(cnfg->ctrl, channel_id, NULL); in cfcnfg_linkup_rsp()
406 caif_assert(phyinfo->id == phyid); in cfcnfg_linkup_rsp()
407 caif_assert(phyinfo->phy_layer != NULL); in cfcnfg_linkup_rsp()
408 caif_assert(phyinfo->phy_layer->id == phyid); in cfcnfg_linkup_rsp()
410 adapt_layer->id = channel_id; in cfcnfg_linkup_rsp()
414 servicel = cfvei_create(channel_id, &phyinfo->dev_info); in cfcnfg_linkup_rsp()
418 &phyinfo->dev_info); in cfcnfg_linkup_rsp()
421 netdev = phyinfo->dev_info.dev; in cfcnfg_linkup_rsp()
422 servicel = cfrfml_create(channel_id, &phyinfo->dev_info, in cfcnfg_linkup_rsp()
423 netdev->mtu); in cfcnfg_linkup_rsp()
426 servicel = cfutill_create(channel_id, &phyinfo->dev_info); in cfcnfg_linkup_rsp()
429 servicel = cfvidl_create(channel_id, &phyinfo->dev_info); in cfcnfg_linkup_rsp()
432 servicel = cfdbgl_create(channel_id, &phyinfo->dev_info); in cfcnfg_linkup_rsp()
435 pr_err("Protocol error. Link setup response - unknown channel type\n"); in cfcnfg_linkup_rsp()
440 layer_set_dn(servicel, cnfg->mux); in cfcnfg_linkup_rsp()
441 cfmuxl_set_uplayer(cnfg->mux, servicel, channel_id); in cfcnfg_linkup_rsp()
447 servicel->ctrlcmd(servicel, CAIF_CTRLCMD_INIT_RSP, 0); in cfcnfg_linkup_rsp()
465 mutex_lock(&cnfg->lock); in cfcnfg_add_phy_layer()
467 /* CAIF protocol allow maximum 6 link-layers */ in cfcnfg_add_phy_layer()
469 phyid = (dev->ifindex + i) & 0x7; in cfcnfg_add_phy_layer()
476 res = -EEXIST; in cfcnfg_add_phy_layer()
482 res = -ENOMEM; in cfcnfg_add_phy_layer()
486 phy_layer->id = phyid; in cfcnfg_add_phy_layer()
487 phyinfo->pref = pref; in cfcnfg_add_phy_layer()
488 phyinfo->id = phyid; in cfcnfg_add_phy_layer()
489 phyinfo->dev_info.id = phyid; in cfcnfg_add_phy_layer()
490 phyinfo->dev_info.dev = dev; in cfcnfg_add_phy_layer()
491 phyinfo->phy_layer = phy_layer; in cfcnfg_add_phy_layer()
492 phyinfo->ifindex = dev->ifindex; in cfcnfg_add_phy_layer()
493 phyinfo->head_room = head_room; in cfcnfg_add_phy_layer()
494 phyinfo->use_fcs = fcs; in cfcnfg_add_phy_layer()
499 res = -ENOMEM; in cfcnfg_add_phy_layer()
502 phyinfo->frm_layer = frml; in cfcnfg_add_phy_layer()
503 layer_set_up(frml, cnfg->mux); in cfcnfg_add_phy_layer()
506 link_support->id = phyid; in cfcnfg_add_phy_layer()
516 list_add_rcu(&phyinfo->node, &cnfg->phys); in cfcnfg_add_phy_layer()
518 mutex_unlock(&cnfg->lock); in cfcnfg_add_phy_layer()
523 mutex_unlock(&cnfg->lock); in cfcnfg_add_phy_layer()
534 phyinfo = cfcnfg_get_phyinfo_rcu(cnfg, phy_layer->id); in cfcnfg_set_phy_state()
537 return -ENODEV; in cfcnfg_set_phy_state()
540 if (phyinfo->up == up) { in cfcnfg_set_phy_state()
544 phyinfo->up = up; in cfcnfg_set_phy_state()
547 cffrml_hold(phyinfo->frm_layer); in cfcnfg_set_phy_state()
548 cfmuxl_set_dnlayer(cnfg->mux, phyinfo->frm_layer, in cfcnfg_set_phy_state()
549 phy_layer->id); in cfcnfg_set_phy_state()
551 cfmuxl_remove_dnlayer(cnfg->mux, phy_layer->id); in cfcnfg_set_phy_state()
552 cffrml_put(phyinfo->frm_layer); in cfcnfg_set_phy_state()
568 mutex_lock(&cnfg->lock); in cfcnfg_del_phy_layer()
570 phyid = phy_layer->id; in cfcnfg_del_phy_layer()
574 mutex_unlock(&cnfg->lock); in cfcnfg_del_phy_layer()
577 caif_assert(phyid == phyinfo->id); in cfcnfg_del_phy_layer()
578 caif_assert(phy_layer == phyinfo->phy_layer); in cfcnfg_del_phy_layer()
579 caif_assert(phy_layer->id == phyid); in cfcnfg_del_phy_layer()
580 caif_assert(phyinfo->frm_layer->id == phyid); in cfcnfg_del_phy_layer()
582 list_del_rcu(&phyinfo->node); in cfcnfg_del_phy_layer()
586 if (cffrml_refcnt_read(phyinfo->frm_layer) != 0) { in cfcnfg_del_phy_layer()
588 list_add_rcu(&phyinfo->node, &cnfg->phys); in cfcnfg_del_phy_layer()
589 mutex_unlock(&cnfg->lock); in cfcnfg_del_phy_layer()
590 return -EAGAIN; in cfcnfg_del_phy_layer()
593 frml = phyinfo->frm_layer; in cfcnfg_del_phy_layer()
594 frml_dn = frml->dn; in cfcnfg_del_phy_layer()
603 if (phyinfo->phy_layer != frml_dn) in cfcnfg_del_phy_layer()
608 mutex_unlock(&cnfg->lock); in cfcnfg_del_phy_layer()