Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 1 | /* |
| 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 |
| 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 Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 12 | #include <linux/kref.h> |
sjur.brandeland@stericsson.com | 43e3692 | 2011-05-13 02:44:03 +0000 | [diff] [blame] | 13 | #include <linux/rculist.h> |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 14 | |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 15 | struct cfsrvl { |
| 16 | struct cflayer layer; |
| 17 | bool open; |
| 18 | bool phy_flow_on; |
| 19 | bool modem_flow_on; |
Sjur Braendeland | b1c7424 | 2010-06-17 06:55:38 +0000 | [diff] [blame] | 20 | bool supports_flowctrl; |
sjur.brandeland@stericsson.com | 43e3692 | 2011-05-13 02:44:03 +0000 | [diff] [blame] | 21 | void (*release)(struct cflayer *layer); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 22 | struct dev_info dev_info; |
sjur.brandeland@stericsson.com | 43e3692 | 2011-05-13 02:44:03 +0000 | [diff] [blame] | 23 | void (*hold)(struct cflayer *lyr); |
| 24 | void (*put)(struct cflayer *lyr); |
| 25 | struct rcu_head rcu; |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info); |
| 29 | struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info); |
| 30 | struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info); |
| 31 | struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info); |
Sjur Braendeland | a7da1f5 | 2010-06-17 06:55:39 +0000 | [diff] [blame] | 32 | struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info, |
| 33 | int mtu_size); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 34 | struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info); |
sjur.brandeland@stericsson.com | 43e3692 | 2011-05-13 02:44:03 +0000 | [diff] [blame] | 35 | |
| 36 | void cfsrvl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, |
| 37 | int phyid); |
| 38 | |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 39 | bool cfsrvl_phyid_match(struct cflayer *layer, int phyid); |
Stephen Hemminger | 73d6ac6 | 2011-04-11 10:43:50 +0000 | [diff] [blame] | 40 | |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 41 | void cfsrvl_init(struct cfsrvl *service, |
Sjur Braendeland | b1c7424 | 2010-06-17 06:55:38 +0000 | [diff] [blame] | 42 | u8 channel_id, |
| 43 | struct dev_info *dev_info, |
| 44 | bool supports_flowctrl); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 45 | bool cfsrvl_ready(struct cfsrvl *service, int *err); |
| 46 | u8 cfsrvl_getphyid(struct cflayer *layer); |
| 47 | |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 48 | static inline void cfsrvl_get(struct cflayer *layr) |
| 49 | { |
sjur.brandeland@stericsson.com | 43e3692 | 2011-05-13 02:44:03 +0000 | [diff] [blame] | 50 | struct cfsrvl *s = container_of(layr, struct cfsrvl, layer); |
| 51 | if (layr == NULL || layr->up == NULL || s->hold == NULL) |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 52 | return; |
sjur.brandeland@stericsson.com | 43e3692 | 2011-05-13 02:44:03 +0000 | [diff] [blame] | 53 | |
| 54 | s->hold(layr->up); |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | static inline void cfsrvl_put(struct cflayer *layr) |
| 58 | { |
sjur.brandeland@stericsson.com | 43e3692 | 2011-05-13 02:44:03 +0000 | [diff] [blame] | 59 | struct cfsrvl *s = container_of(layr, struct cfsrvl, layer); |
| 60 | if (layr == NULL || layr->up == NULL || s->hold == NULL) |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 61 | return; |
Sjur Braendeland | a7da1f5 | 2010-06-17 06:55:39 +0000 | [diff] [blame] | 62 | |
sjur.brandeland@stericsson.com | 43e3692 | 2011-05-13 02:44:03 +0000 | [diff] [blame] | 63 | s->put(layr->up); |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 64 | } |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 65 | #endif /* CFSRVL_H_ */ |