xref: /openbmc/linux/include/net/caif/cfsrvl.h (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1*af873fceSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
209009f30SSjur Braendeland /*
309009f30SSjur Braendeland  * Copyright (C) ST-Ericsson AB 2010
426ee65e6Ssjur.brandeland@stericsson.com  * Author:	Sjur Brendeland
509009f30SSjur Braendeland  */
609009f30SSjur Braendeland 
709009f30SSjur Braendeland #ifndef CFSRVL_H_
809009f30SSjur Braendeland #define CFSRVL_H_
909009f30SSjur Braendeland #include <linux/list.h>
1009009f30SSjur Braendeland #include <linux/stddef.h>
1109009f30SSjur Braendeland #include <linux/types.h>
125b208656SSjur Braendeland #include <linux/kref.h>
1343e36921Ssjur.brandeland@stericsson.com #include <linux/rculist.h>
145b208656SSjur Braendeland 
1509009f30SSjur Braendeland struct cfsrvl {
1609009f30SSjur Braendeland 	struct cflayer layer;
1709009f30SSjur Braendeland 	bool open;
1809009f30SSjur Braendeland 	bool phy_flow_on;
1909009f30SSjur Braendeland 	bool modem_flow_on;
20b1c74247SSjur Braendeland 	bool supports_flowctrl;
2143e36921Ssjur.brandeland@stericsson.com 	void (*release)(struct cflayer *layer);
2209009f30SSjur Braendeland 	struct dev_info dev_info;
2343e36921Ssjur.brandeland@stericsson.com 	void (*hold)(struct cflayer *lyr);
2443e36921Ssjur.brandeland@stericsson.com 	void (*put)(struct cflayer *lyr);
2543e36921Ssjur.brandeland@stericsson.com 	struct rcu_head rcu;
2609009f30SSjur Braendeland };
2709009f30SSjur Braendeland 
2809009f30SSjur Braendeland struct cflayer *cfvei_create(u8 linkid, struct dev_info *dev_info);
2909009f30SSjur Braendeland struct cflayer *cfdgml_create(u8 linkid, struct dev_info *dev_info);
3009009f30SSjur Braendeland struct cflayer *cfutill_create(u8 linkid, struct dev_info *dev_info);
3109009f30SSjur Braendeland struct cflayer *cfvidl_create(u8 linkid, struct dev_info *dev_info);
32a7da1f55SSjur Braendeland struct cflayer *cfrfml_create(u8 linkid, struct dev_info *dev_info,
33a7da1f55SSjur Braendeland 				int mtu_size);
3409009f30SSjur Braendeland struct cflayer *cfdbgl_create(u8 linkid, struct dev_info *dev_info);
3543e36921Ssjur.brandeland@stericsson.com 
3609009f30SSjur Braendeland bool cfsrvl_phyid_match(struct cflayer *layer, int phyid);
3773d6ac63SStephen Hemminger 
3809009f30SSjur Braendeland void cfsrvl_init(struct cfsrvl *service,
3909009f30SSjur Braendeland 			u8 channel_id,
40b1c74247SSjur Braendeland 			struct dev_info *dev_info,
41b1c74247SSjur Braendeland 			bool supports_flowctrl);
4209009f30SSjur Braendeland bool cfsrvl_ready(struct cfsrvl *service, int *err);
4309009f30SSjur Braendeland u8 cfsrvl_getphyid(struct cflayer *layer);
4409009f30SSjur Braendeland 
cfsrvl_get(struct cflayer * layr)455b208656SSjur Braendeland static inline void cfsrvl_get(struct cflayer *layr)
465b208656SSjur Braendeland {
4743e36921Ssjur.brandeland@stericsson.com 	struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
4843e36921Ssjur.brandeland@stericsson.com 	if (layr == NULL || layr->up == NULL || s->hold == NULL)
495b208656SSjur Braendeland 		return;
5043e36921Ssjur.brandeland@stericsson.com 
5143e36921Ssjur.brandeland@stericsson.com 	s->hold(layr->up);
525b208656SSjur Braendeland }
535b208656SSjur Braendeland 
cfsrvl_put(struct cflayer * layr)545b208656SSjur Braendeland static inline void cfsrvl_put(struct cflayer *layr)
555b208656SSjur Braendeland {
5643e36921Ssjur.brandeland@stericsson.com 	struct cfsrvl *s = container_of(layr, struct cfsrvl, layer);
5743e36921Ssjur.brandeland@stericsson.com 	if (layr == NULL || layr->up == NULL || s->hold == NULL)
585b208656SSjur Braendeland 		return;
59a7da1f55SSjur Braendeland 
6043e36921Ssjur.brandeland@stericsson.com 	s->put(layr->up);
615b208656SSjur Braendeland }
6209009f30SSjur Braendeland #endif				/* CFSRVL_H_ */
63