diff options
| author | sjur.brandeland@stericsson.com <sjur.brandeland@stericsson.com> | 2011-05-12 22:44:05 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2011-05-15 17:45:55 -0400 |
| commit | bee925db9a77a5736596dcf6f91d0879f5ee915b (patch) | |
| tree | 57a3b499d5b8ec3cb9d36be674e165fa1e7eed42 /include/net/caif | |
| parent | b3ccfbe4098a5542177d0f34e8979f32e7d606e1 (diff) | |
caif: prepare support for namespaces
Use struct net to reference CAIF configuration object instead of static variables.
Refactor functions caif_connect_client, caif_disconnect_client and squach
files cfcnfg.c and caif_config_utils.
Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net/caif')
| -rw-r--r-- | include/net/caif/caif_dev.h | 24 | ||||
| -rw-r--r-- | include/net/caif/cfcnfg.h | 71 |
2 files changed, 14 insertions, 81 deletions
diff --git a/include/net/caif/caif_dev.h b/include/net/caif/caif_dev.h index 6638435525fc..c011281d92c0 100644 --- a/include/net/caif/caif_dev.h +++ b/include/net/caif/caif_dev.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include <net/caif/cfcnfg.h> | 11 | #include <net/caif/cfcnfg.h> |
| 12 | #include <linux/caif/caif_socket.h> | 12 | #include <linux/caif/caif_socket.h> |
| 13 | #include <linux/if.h> | 13 | #include <linux/if.h> |
| 14 | #include <linux/net.h> | ||
| 14 | 15 | ||
| 15 | /** | 16 | /** |
| 16 | * struct caif_param - CAIF parameters. | 17 | * struct caif_param - CAIF parameters. |
| @@ -62,16 +63,18 @@ struct caif_connect_request { | |||
| 62 | * E.g. CAIF Socket will call this function for each socket it connects | 63 | * E.g. CAIF Socket will call this function for each socket it connects |
| 63 | * and have one client_layer instance for each socket. | 64 | * and have one client_layer instance for each socket. |
| 64 | */ | 65 | */ |
| 65 | int caif_connect_client(struct caif_connect_request *conn_req, | 66 | int caif_connect_client(struct net *net, |
| 67 | struct caif_connect_request *conn_req, | ||
| 66 | struct cflayer *client_layer, int *ifindex, | 68 | struct cflayer *client_layer, int *ifindex, |
| 67 | int *headroom, int *tailroom); | 69 | int *headroom, int *tailroom); |
| 68 | 70 | ||
| 69 | /** | 71 | /** |
| 70 | * caif_disconnect_client - Disconnects a client from the CAIF stack. | 72 | * caif_disconnect_client - Disconnects a client from the CAIF stack. |
| 71 | * | 73 | * |
| 72 | * @client_layer: Client layer to be removed. | 74 | * @client_layer: Client layer to be disconnected. |
| 73 | */ | 75 | */ |
| 74 | int caif_disconnect_client(struct cflayer *client_layer); | 76 | int caif_disconnect_client(struct net *net, struct cflayer *client_layer); |
| 77 | |||
| 75 | 78 | ||
| 76 | /** | 79 | /** |
| 77 | * caif_client_register_refcnt - register ref-count functions provided by client. | 80 | * caif_client_register_refcnt - register ref-count functions provided by client. |
| @@ -91,21 +94,6 @@ void caif_client_register_refcnt(struct cflayer *adapt_layer, | |||
| 91 | void (*hold)(struct cflayer *lyr), | 94 | void (*hold)(struct cflayer *lyr), |
| 92 | void (*put)(struct cflayer *lyr)); | 95 | void (*put)(struct cflayer *lyr)); |
| 93 | /** | 96 | /** |
| 94 | * caif_connect_req_to_link_param - Translate configuration parameters | ||
| 95 | * from socket format to internal format. | ||
| 96 | * @cnfg: Pointer to configuration handler | ||
| 97 | * @con_req: Configuration parameters supplied in function | ||
| 98 | * caif_connect_client | ||
| 99 | * @channel_setup_param: Parameters supplied to the CAIF Core stack for | ||
| 100 | * setting up channels. | ||
| 101 | * | ||
| 102 | */ | ||
| 103 | |||
| 104 | int caif_connect_req_to_link_param(struct cfcnfg *cnfg, | ||
| 105 | struct caif_connect_request *con_req, | ||
| 106 | struct cfctrl_link_param *setup_param); | ||
| 107 | |||
| 108 | /** | ||
| 109 | * caif_free_client - Free memory used to manage the client in the CAIF Stack. | 97 | * caif_free_client - Free memory used to manage the client in the CAIF Stack. |
| 110 | * | 98 | * |
| 111 | * @client_layer: Client layer to be removed. | 99 | * @client_layer: Client layer to be removed. |
diff --git a/include/net/caif/cfcnfg.h b/include/net/caif/cfcnfg.h index e0a1eb5d7eaf..3e93a4a4b677 100644 --- a/include/net/caif/cfcnfg.h +++ b/include/net/caif/cfcnfg.h | |||
| @@ -46,6 +46,12 @@ enum cfcnfg_phy_preference { | |||
| 46 | }; | 46 | }; |
| 47 | 47 | ||
| 48 | /** | 48 | /** |
| 49 | * cfcnfg_create() - Get the CAIF configuration object given network. | ||
| 50 | * @net: Network for the CAIF configuration object. | ||
| 51 | */ | ||
| 52 | struct cfcnfg *get_cfcnfg(struct net *net); | ||
| 53 | |||
| 54 | /** | ||
| 49 | * cfcnfg_create() - Create the CAIF configuration object. | 55 | * cfcnfg_create() - Create the CAIF configuration object. |
| 50 | */ | 56 | */ |
| 51 | struct cfcnfg *cfcnfg_create(void); | 57 | struct cfcnfg *cfcnfg_create(void); |
| @@ -65,17 +71,15 @@ void cfcnfg_remove(struct cfcnfg *cfg); | |||
| 65 | * @dev: Pointer to link layer device | 71 | * @dev: Pointer to link layer device |
| 66 | * @phy_layer: Specify the physical layer. The transmit function | 72 | * @phy_layer: Specify the physical layer. The transmit function |
| 67 | * MUST be set in the structure. | 73 | * 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. | 74 | * @pref: The phy (link layer) preference. |
| 71 | * @fcs: Specify if checksum is used in CAIF Framing Layer. | 75 | * @fcs: Specify if checksum is used in CAIF Framing Layer. |
| 72 | * @stx: Specify if Start Of Frame extension is used. | 76 | * @stx: Specify if Start Of Frame eXtention is used. |
| 73 | */ | 77 | */ |
| 74 | 78 | ||
| 75 | void | 79 | void |
| 76 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, | 80 | cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, |
| 77 | struct net_device *dev, struct cflayer *phy_layer, | 81 | struct net_device *dev, struct cflayer *phy_layer, |
| 78 | u16 *phyid, enum cfcnfg_phy_preference pref, | 82 | enum cfcnfg_phy_preference pref, |
| 79 | bool fcs, bool stx); | 83 | bool fcs, bool stx); |
| 80 | 84 | ||
| 81 | /** | 85 | /** |
| @@ -88,65 +92,6 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type, | |||
| 88 | int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer); | 92 | int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer); |
| 89 | 93 | ||
| 90 | /** | 94 | /** |
| 91 | * cfcnfg_disconn_adapt_layer - Disconnects an adaptation layer. | ||
| 92 | * | ||
| 93 | * @cnfg: Pointer to a CAIF configuration object, created by | ||
| 94 | * cfcnfg_create(). | ||
| 95 | * @adap_layer: Adaptation layer to be removed. | ||
| 96 | */ | ||
| 97 | int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg, | ||
| 98 | struct cflayer *adap_layer); | ||
| 99 | |||
| 100 | /** | ||
| 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 | /** | ||
| 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 | ||
| 114 | * cfcnfg_create(). | ||
| 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. | ||
| 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. | ||
| 123 | */ | ||
| 124 | int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg, | ||
| 125 | struct cfctrl_link_param *param, | ||
| 126 | struct cflayer *adap_layer, | ||
| 127 | int *ifindex, | ||
| 128 | int *proto_head, | ||
| 129 | int *proto_tail); | ||
| 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 | /** | ||
| 142 | * cfcnfg_get_id_from_ifi() - Get the Physical Identifier of ifindex, | ||
| 143 | * it matches caif physical id with the kernel interface id. | ||
| 144 | * @cnfg: Configuration object | ||
| 145 | * @ifi: ifindex obtained from socket.c bindtodevice. | ||
| 146 | */ | ||
| 147 | int cfcnfg_get_id_from_ifi(struct cfcnfg *cnfg, int ifi); | ||
| 148 | |||
| 149 | /** | ||
| 150 | * cfcnfg_set_phy_state() - Set the state of the physical interface device. | 95 | * cfcnfg_set_phy_state() - Set the state of the physical interface device. |
| 151 | * @cnfg: Configuration object | 96 | * @cnfg: Configuration object |
| 152 | * @phy_layer: Physical Layer representation | 97 | * @phy_layer: Physical Layer representation |
