blob: cd47705c2cc378cd0c847569adc0768877100be6 [file] [log] [blame]
Sjur Braendeland09009f32010-03-30 13:56:21 +00001/*
2 * Copyright (C) ST-Ericsson AB 2010
sjur.brandeland@stericsson.com26ee65e2013-04-22 23:57:01 +00003 * Author: Sjur Brendeland
Sjur Braendeland09009f32010-03-30 13:56:21 +00004 * License terms: GNU General Public License (GPL) version 2
5 */
6
7#ifndef CFSRVL_H_
8#define CFSRVL_H_
9#include <linux/list.h>
10#include <linux/stddef.h>
11#include <linux/types.h>
Sjur Braendeland5b208652010-04-28 08:54:36 +000012#include <linux/kref.h>
sjur.brandeland@stericsson.com43e36922011-05-13 02:44:03 +000013#include <linux/rculist.h>
Sjur Braendeland5b208652010-04-28 08:54:36 +000014
Sjur Braendeland09009f32010-03-30 13:56:21 +000015struct cfsrvl {
16 struct cflayer layer;
17 bool open;
18 bool phy_flow_on;
19 bool modem_flow_on;
Sjur Braendelandb1c74242010-06-17 06:55:38 +000020 bool supports_flowctrl;
sjur.brandeland@stericsson.com43e36922011-05-13 02:44:03 +000021 void (*release)(struct cflayer *layer);
Sjur Braendeland09009f32010-03-30 13:56:21 +000022 struct dev_info dev_info;
sjur.brandeland@stericsson.com43e36922011-05-13 02:44:03 +000023 void (*hold)(struct cflayer *lyr);
24 void (*put)(struct cflayer *lyr);
25 struct rcu_head rcu;
Sjur Braendeland09009f32010-03-30 13:56:21 +000026};
27
28struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info);
29struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info);
30struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info);
31struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info);
Sjur Braendelanda7da1f52010-06-17 06:55:39 +000032struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info,
33 int mtu_size);
Sjur Braendeland09009f32010-03-30 13:56:21 +000034struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info);
sjur.brandeland@stericsson.com43e36922011-05-13 02:44:03 +000035
36void cfsrvl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl,
37 int phyid);
38
Sjur Braendeland09009f32010-03-30 13:56:21 +000039bool cfsrvl_phyid_match(struct cflayer *layer, int phyid);
Stephen Hemminger73d6ac62011-04-11 10:43:50 +000040
Sjur Braendeland09009f32010-03-30 13:56:21 +000041void cfsrvl_init(struct cfsrvl *service,
Sjur Braendelandb1c74242010-06-17 06:55:38 +000042 u8 channel_id,
43 struct dev_info *dev_info,
44 bool supports_flowctrl);
Sjur Braendeland09009f32010-03-30 13:56:21 +000045bool cfsrvl_ready(struct cfsrvl *service, int *err);
46u8 cfsrvl_getphyid(struct cflayer *layer);
47
Sjur Braendeland5b208652010-04-28 08:54:36 +000048static inline void cfsrvl_get(struct cflayer *layr)
49{
sjur.brandeland@stericsson.com43e36922011-05-13 02:44:03 +000050 struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
51 if (layr == NULL || layr->up == NULL || s->hold == NULL)
Sjur Braendeland5b208652010-04-28 08:54:36 +000052 return;
sjur.brandeland@stericsson.com43e36922011-05-13 02:44:03 +000053
54 s->hold(layr->up);
Sjur Braendeland5b208652010-04-28 08:54:36 +000055}
56
57static inline void cfsrvl_put(struct cflayer *layr)
58{
sjur.brandeland@stericsson.com43e36922011-05-13 02:44:03 +000059 struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
60 if (layr == NULL || layr->up == NULL || s->hold == NULL)
Sjur Braendeland5b208652010-04-28 08:54:36 +000061 return;
Sjur Braendelanda7da1f52010-06-17 06:55:39 +000062
sjur.brandeland@stericsson.com43e36922011-05-13 02:44:03 +000063 s->put(layr->up);
Sjur Braendeland5b208652010-04-28 08:54:36 +000064}
Sjur Braendeland09009f32010-03-30 13:56:21 +000065#endif /* CFSRVL_H_ */