diff options
Diffstat (limited to 'net/caif/cfcnfg.c')
-rw-r--r-- | net/caif/cfcnfg.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c index cff2dcb9efe4..1c29189b344d 100644 --- a/net/caif/cfcnfg.c +++ b/net/caif/cfcnfg.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/stddef.h> | 7 | #include <linux/stddef.h> |
8 | #include <linux/slab.h> | 8 | #include <linux/slab.h> |
9 | #include <linux/netdevice.h> | ||
9 | #include <net/caif/caif_layer.h> | 10 | #include <net/caif/caif_layer.h> |
10 | #include <net/caif/cfpkt.h> | 11 | #include <net/caif/cfpkt.h> |
11 | #include <net/caif/cfcnfg.h> | 12 | #include <net/caif/cfcnfg.h> |
@@ -42,6 +43,15 @@ struct cfcnfg_phyinfo { | |||
42 | 43 | ||
43 | /* Information about the physical device */ | 44 | /* Information about the physical device */ |
44 | struct dev_info dev_info; | 45 | struct dev_info dev_info; |
46 | |||
47 | /* Interface index */ | ||
48 | int ifindex; | ||
49 | |||
50 | /* Use Start of frame extension */ | ||
51 | bool use_stx; | ||
52 | |||
53 | /* Use Start of frame checksum */ | ||
54 | bool use_fcs; | ||
45 | }; | 55 | }; |
46 | 56 | ||
47 | struct cfcnfg { | 57 | struct cfcnfg { |
@@ -249,9 +259,20 @@ static void cfcnfg_linkdestroy_rsp(struct cflayer *layer, u8 channel_id) | |||
249 | { | 259 | { |
250 | } | 260 | } |
251 | 261 | ||
262 | int protohead[CFCTRL_SRV_MASK] = { | ||
263 | [CFCTRL_SRV_VEI] = 4, | ||
264 | [CFCTRL_SRV_DATAGRAM] = 7, | ||
265 | [CFCTRL_SRV_UTIL] = 4, | ||
266 | [CFCTRL_SRV_RFM] = 3, | ||
267 | [CFCTRL_SRV_DBG] = 3, | ||
268 | }; | ||
269 | |||
252 | int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, | 270 | int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, |
253 | struct cfctrl_link_param *param, | 271 | struct cfctrl_link_param *param, |
254 | struct cflayer *adap_layer) | 272 | struct cflayer *adap_layer, |
273 | int *ifindex, | ||
274 | int *proto_head, | ||
275 | int *proto_tail) | ||
255 | { | 276 | { |
256 | struct cflayer *frml; | 277 | struct cflayer *frml; |
257 | if (adap_layer == NULL) { | 278 | if (adap_layer == NULL) { |
@@ -277,6 +298,14 @@ int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, | |||
277 | param->phyid); | 298 | param->phyid); |
278 | caif_assert(cnfg->phy_layers[param->phyid].phy_layer->id == | 299 | caif_assert(cnfg->phy_layers[param->phyid].phy_layer->id == |
279 | param->phyid); | 300 | param->phyid); |
301 | |||
302 | *ifindex = cnfg->phy_layers[param->phyid].ifindex; | ||
303 | *proto_head = | ||
304 | protohead[param->linktype]+ | ||
305 | (cnfg->phy_layers[param->phyid].use_stx ? 1 : 0); | ||
306 | |||
307 | *proto_tail = 2; | ||
308 | |||
280 | /* FIXME: ENUMERATE INITIALLY WHEN ACTIVATING PHYSICAL INTERFACE */ | 309 | /* FIXME: ENUMERATE INITIALLY WHEN ACTIVATING PHYSICAL INTERFACE */ |
281 | cfctrl_enum_req(cnfg->ctrl, param->phyid); | 310 | cfctrl_enum_req(cnfg->ctrl, param->phyid); |
282 | return cfctrl_linkup_request(cnfg->ctrl, param, adap_layer); | 311 | return cfctrl_linkup_request(cnfg->ctrl, param, adap_layer); |
@@ -298,6 +327,8 @@ cfcnfg_linkup_rsp(struct cflayer *layer, u8 channel_id, enum cfctrl_srv serv, | |||
298 | struct cfcnfg *cnfg = container_obj(layer); | 327 | struct cfcnfg *cnfg = container_obj(layer); |
299 | struct cflayer *servicel = NULL; | 328 | struct cflayer *servicel = NULL; |
300 | struct cfcnfg_phyinfo *phyinfo; | 329 | struct cfcnfg_phyinfo *phyinfo; |
330 | struct net_device *netdev; | ||
331 | |||
301 | if (adapt_layer == NULL) { | 332 | if (adapt_layer == NULL) { |
302 | pr_debug("CAIF: %s(): link setup response " | 333 | pr_debug("CAIF: %s(): link setup response " |
303 | "but no client exist, send linkdown back\n", | 334 | "but no client exist, send linkdown back\n", |
@@ -329,8 +360,9 @@ cfcnfg_linkup_rsp(struct cflayer *layer, u8 channel_id, enum cfctrl_srv serv, | |||
329 | servicel = cfdgml_create(channel_id, &phyinfo->dev_info); | 360 | servicel = cfdgml_create(channel_id, &phyinfo->dev_info); |
330 | break; | 361 | break; |
331 | case CFCTRL_SRV_RFM: | 362 | case CFCTRL_SRV_RFM: |
363 | netdev = phyinfo->dev_info.dev; | ||
332 | servicel = cfrfml_create(channel_id, &phyinfo->dev_info, | 364 | servicel = cfrfml_create(channel_id, &phyinfo->dev_info, |
333 | RFM_FRAGMENT_SIZE); | 365 | netdev->mtu); |
334 | break; | 366 | break; |
335 | case CFCTRL_SRV_UTIL: | 367 | case CFCTRL_SRV_UTIL: |
336 | servicel = cfutill_create(channel_id, &phyinfo->dev_info); | 368 | servicel = cfutill_create(channel_id, &phyinfo->dev_info); |
@@ -361,8 +393,8 @@ cfcnfg_linkup_rsp(struct cflayer *layer, u8 channel_id, enum cfctrl_srv serv, | |||
361 | 393 | ||
362 | void | 394 | void |
363 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, | 395 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, |
364 | void *dev, struct cflayer *phy_layer, u16 *phyid, | 396 | struct net_device *dev, struct cflayer *phy_layer, |
365 | enum cfcnfg_phy_preference pref, | 397 | u16 *phyid, enum cfcnfg_phy_preference pref, |
366 | bool fcs, bool stx) | 398 | bool fcs, bool stx) |
367 | { | 399 | { |
368 | struct cflayer *frml; | 400 | struct cflayer *frml; |
@@ -416,6 +448,10 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, | |||
416 | cnfg->phy_layers[*phyid].dev_info.dev = dev; | 448 | cnfg->phy_layers[*phyid].dev_info.dev = dev; |
417 | cnfg->phy_layers[*phyid].phy_layer = phy_layer; | 449 | cnfg->phy_layers[*phyid].phy_layer = phy_layer; |
418 | cnfg->phy_layers[*phyid].phy_ref_count = 0; | 450 | cnfg->phy_layers[*phyid].phy_ref_count = 0; |
451 | cnfg->phy_layers[*phyid].ifindex = dev->ifindex; | ||
452 | cnfg->phy_layers[*phyid].use_stx = stx; | ||
453 | cnfg->phy_layers[*phyid].use_fcs = fcs; | ||
454 | |||
419 | phy_layer->type = phy_type; | 455 | phy_layer->type = phy_type; |
420 | frml = cffrml_create(*phyid, fcs); | 456 | frml = cffrml_create(*phyid, fcs); |
421 | if (!frml) { | 457 | if (!frml) { |