2 * Copyright (C) ST-Ericsson AB 2010
3 * Author: Sjur Brendeland sjur.brandeland@stericsson.com
4 * License terms: GNU General Public License (GPL) version 2
7 #include <linux/module.h>
8 #include <linux/spinlock.h>
9 #include <net/caif/cfctrl.h>
10 #include <net/caif/cfcnfg.h>
11 #include <net/caif/caif_dev.h>
13 int connect_req_to_link_param(struct cfcnfg
*cnfg
,
14 struct caif_connect_request
*s
,
15 struct cfctrl_link_param
*l
)
17 struct dev_info
*dev_info
;
18 enum cfcnfg_phy_preference pref
;
21 memset(l
, 0, sizeof(*l
));
22 /* In caif protocol low value is high priority */
23 l
->priority
= CAIF_PRIO_MAX
- s
->priority
+ 1;
26 res
= cfcnfg_get_id_from_ifi(cnfg
, s
->ifindex
);
32 switch (s
->link_selector
) {
33 case CAIF_LINK_HIGH_BANDW
:
34 pref
= CFPHYPREF_HIGH_BW
;
36 case CAIF_LINK_LOW_LATENCY
:
37 pref
= CFPHYPREF_LOW_LAT
;
42 dev_info
= cfcnfg_get_phyid(cnfg
, pref
);
45 l
->phyid
= dev_info
->id
;
47 switch (s
->protocol
) {
49 l
->linktype
= CFCTRL_SRV_VEI
;
50 if (s
->sockaddr
.u
.at
.type
== CAIF_ATTYPE_PLAIN
)
53 l
->chtype
= s
->sockaddr
.u
.at
.type
;
56 case CAIFPROTO_DATAGRAM
:
57 l
->linktype
= CFCTRL_SRV_DATAGRAM
;
59 l
->u
.datagram
.connid
= s
->sockaddr
.u
.dgm
.connection_id
;
61 case CAIFPROTO_DATAGRAM_LOOP
:
62 l
->linktype
= CFCTRL_SRV_DATAGRAM
;
65 l
->u
.datagram
.connid
= s
->sockaddr
.u
.dgm
.connection_id
;
68 l
->linktype
= CFCTRL_SRV_RFM
;
69 l
->u
.datagram
.connid
= s
->sockaddr
.u
.rfm
.connection_id
;
70 strncpy(l
->u
.rfm
.volume
, s
->sockaddr
.u
.rfm
.volume
,
71 sizeof(l
->u
.rfm
.volume
)-1);
72 l
->u
.rfm
.volume
[sizeof(l
->u
.rfm
.volume
)-1] = 0;
75 l
->linktype
= CFCTRL_SRV_UTIL
;
78 strncpy(l
->u
.utility
.name
, s
->sockaddr
.u
.util
.service
,
79 sizeof(l
->u
.utility
.name
)-1);
80 l
->u
.utility
.name
[sizeof(l
->u
.utility
.name
)-1] = 0;
81 caif_assert(sizeof(l
->u
.utility
.name
) > 10);
82 l
->u
.utility
.paramlen
= s
->param
.size
;
83 if (l
->u
.utility
.paramlen
> sizeof(l
->u
.utility
.params
))
84 l
->u
.utility
.paramlen
= sizeof(l
->u
.utility
.params
);
86 memcpy(l
->u
.utility
.params
, s
->param
.data
,
87 l
->u
.utility
.paramlen
);
91 l
->linktype
= CFCTRL_SRV_DBG
;
92 l
->endpoint
= s
->sockaddr
.u
.dbg
.service
;
93 l
->chtype
= s
->sockaddr
.u
.dbg
.type
;