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 CFCNFG_H_ |
| 8 | #define CFCNFG_H_ |
| 9 | #include <linux/spinlock.h> |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 10 | #include <linux/netdevice.h> |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 11 | #include <net/caif/caif_layer.h> |
| 12 | #include <net/caif/cfctrl.h> |
| 13 | |
| 14 | struct cfcnfg; |
| 15 | |
| 16 | /** |
| 17 | * enum cfcnfg_phy_type - Types of physical layers defined in CAIF Stack |
| 18 | * |
| 19 | * @CFPHYTYPE_FRAG: Fragmented frames physical interface. |
| 20 | * @CFPHYTYPE_CAIF: Generic CAIF physical interface |
| 21 | */ |
| 22 | enum cfcnfg_phy_type { |
| 23 | CFPHYTYPE_FRAG = 1, |
| 24 | CFPHYTYPE_CAIF, |
| 25 | CFPHYTYPE_MAX |
| 26 | }; |
| 27 | |
| 28 | /** |
| 29 | * enum cfcnfg_phy_preference - Physical preference HW Abstraction |
| 30 | * |
| 31 | * @CFPHYPREF_UNSPECIFIED: Default physical interface |
| 32 | * |
| 33 | * @CFPHYPREF_LOW_LAT: Default physical interface for low-latency |
| 34 | * traffic |
| 35 | * @CFPHYPREF_HIGH_BW: Default physical interface for high-bandwidth |
| 36 | * traffic |
| 37 | * @CFPHYPREF_LOOP: TEST only Loopback interface simulating modem |
| 38 | * responses. |
| 39 | * |
| 40 | */ |
| 41 | enum cfcnfg_phy_preference { |
| 42 | CFPHYPREF_UNSPECIFIED, |
| 43 | CFPHYPREF_LOW_LAT, |
| 44 | CFPHYPREF_HIGH_BW, |
| 45 | CFPHYPREF_LOOP |
| 46 | }; |
| 47 | |
| 48 | /** |
| 49 | * cfcnfg_create() - Create the CAIF configuration object. |
| 50 | */ |
| 51 | struct cfcnfg *cfcnfg_create(void); |
| 52 | |
| 53 | /** |
| 54 | * cfcnfg_remove() - Remove the CFCNFG object |
| 55 | * @cfg: config object |
| 56 | */ |
| 57 | void cfcnfg_remove(struct cfcnfg *cfg); |
| 58 | |
| 59 | /** |
| 60 | * cfcnfg_add_phy_layer() - Adds a physical layer to the CAIF stack. |
| 61 | * @cnfg: Pointer to a CAIF configuration object, created by |
| 62 | * cfcnfg_create(). |
| 63 | * @phy_type: Specifies the type of physical interface, e.g. |
| 64 | * CFPHYTYPE_FRAG. |
| 65 | * @dev: Pointer to link layer device |
| 66 | * @phy_layer: Specify the physical layer. The transmit function |
| 67 | * MUST be set in the structure. |
| 68 | * @phyid: The assigned physical ID for this layer, used in |
| 69 | * cfcnfg_add_adapt_layer to specify PHY for the link. |
| 70 | * @pref: The phy (link layer) preference. |
| 71 | * @fcs: Specify if checksum is used in CAIF Framing Layer. |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 72 | * @stx: Specify if Start Of Frame extension is used. |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 73 | */ |
| 74 | |
| 75 | void |
| 76 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 77 | struct net_device *dev, struct cflayer *phy_layer, |
| 78 | u16 *phyid, enum cfcnfg_phy_preference pref, |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 79 | bool fcs, bool stx); |
| 80 | |
| 81 | /** |
| 82 | * cfcnfg_del_phy_layer - Deletes an phy layer from the CAIF stack. |
| 83 | * |
| 84 | * @cnfg: Pointer to a CAIF configuration object, created by |
| 85 | * cfcnfg_create(). |
| 86 | * @phy_layer: Adaptation layer to be removed. |
| 87 | */ |
| 88 | int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer); |
| 89 | |
| 90 | /** |
Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 91 | * cfcnfg_disconn_adapt_layer - Disconnects an adaptation layer. |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 92 | * |
| 93 | * @cnfg: Pointer to a CAIF configuration object, created by |
| 94 | * cfcnfg_create(). |
| 95 | * @adap_layer: Adaptation layer to be removed. |
| 96 | */ |
Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 97 | int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg, |
| 98 | struct cflayer *adap_layer); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 99 | |
| 100 | /** |
Sjur Braendeland | 5b20865 | 2010-04-28 08:54:36 +0000 | [diff] [blame] | 101 | * cfcnfg_release_adap_layer - Used by client to release the adaptation layer. |
| 102 | * |
| 103 | * @adap_layer: Adaptation layer. |
| 104 | */ |
| 105 | void cfcnfg_release_adap_layer(struct cflayer *adap_layer); |
| 106 | |
| 107 | /** |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 108 | * cfcnfg_add_adaptation_layer - Add an adaptation layer to the CAIF stack. |
| 109 | * |
| 110 | * The adaptation Layer is where the interface to application or higher-level |
| 111 | * driver functionality is implemented. |
| 112 | * |
| 113 | * @cnfg: Pointer to a CAIF configuration object, created by |
Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 114 | * cfcnfg_create(). |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 115 | * @param: Link setup parameters. |
| 116 | * @adap_layer: Specify the adaptation layer; the receive and |
| 117 | * flow-control functions MUST be set in the structure. |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 118 | * @ifindex: Link layer interface index used for this connection. |
| 119 | * @proto_head: Protocol head-space needed by CAIF protocol, |
| 120 | * excluding link layer. |
| 121 | * @proto_tail: Protocol tail-space needed by CAIF protocol, |
| 122 | * excluding link layer. |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 123 | */ |
Sjur Braendeland | e539d83 | 2010-04-28 08:54:35 +0000 | [diff] [blame] | 124 | int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 125 | struct cfctrl_link_param *param, |
Sjur Braendeland | 2aa40ae | 2010-06-17 06:55:40 +0000 | [diff] [blame] | 126 | struct cflayer *adap_layer, |
| 127 | int *ifindex, |
| 128 | int *proto_head, |
| 129 | int *proto_tail); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 130 | |
| 131 | /** |
| 132 | * cfcnfg_get_phyid() - Get physical ID, given type. |
| 133 | * Returns one of the physical interfaces matching the given type. |
| 134 | * Zero if no match is found. |
| 135 | * @cnfg: Configuration object |
| 136 | * @phy_pref: Caif Link Layer preference |
| 137 | */ |
| 138 | struct dev_info *cfcnfg_get_phyid(struct cfcnfg *cnfg, |
| 139 | enum cfcnfg_phy_preference phy_pref); |
| 140 | |
| 141 | /** |
André Carvalho de Matos | f2527ec | 2010-11-01 11:52:47 +0000 | [diff] [blame] | 142 | * cfcnfg_get_id_from_ifi() - Get the Physical Identifier of ifindex, |
| 143 | * it matches caif physical id with the kernel interface id. |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 144 | * @cnfg: Configuration object |
André Carvalho de Matos | f2527ec | 2010-11-01 11:52:47 +0000 | [diff] [blame] | 145 | * @ifi: ifindex obtained from socket.c bindtodevice. |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 146 | */ |
André Carvalho de Matos | f2527ec | 2010-11-01 11:52:47 +0000 | [diff] [blame] | 147 | int cfcnfg_get_id_from_ifi(struct cfcnfg *cnfg, int ifi); |
Sjur Braendeland | 09009f3 | 2010-03-30 13:56:21 +0000 | [diff] [blame] | 148 | #endif /* CFCNFG_H_ */ |