Skip to content

Commit

Permalink
caif: prepare support for namespaces
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
[email protected] authored and davem330 committed May 15, 2011
1 parent b3ccfbe commit bee925d
Show file tree
Hide file tree
Showing 8 changed files with 176 additions and 261 deletions.
24 changes: 6 additions & 18 deletions include/net/caif/caif_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <net/caif/cfcnfg.h>
#include <linux/caif/caif_socket.h>
#include <linux/if.h>
#include <linux/net.h>

/**
* struct caif_param - CAIF parameters.
Expand Down Expand Up @@ -62,16 +63,18 @@ struct caif_connect_request {
* E.g. CAIF Socket will call this function for each socket it connects
* and have one client_layer instance for each socket.
*/
int caif_connect_client(struct caif_connect_request *conn_req,
int caif_connect_client(struct net *net,
struct caif_connect_request *conn_req,
struct cflayer *client_layer, int *ifindex,
int *headroom, int *tailroom);

/**
* caif_disconnect_client - Disconnects a client from the CAIF stack.
*
* @client_layer: Client layer to be removed.
* @client_layer: Client layer to be disconnected.
*/
int caif_disconnect_client(struct cflayer *client_layer);
int caif_disconnect_client(struct net *net, struct cflayer *client_layer);


/**
* caif_client_register_refcnt - register ref-count functions provided by client.
Expand All @@ -90,21 +93,6 @@ int caif_disconnect_client(struct cflayer *client_layer);
void caif_client_register_refcnt(struct cflayer *adapt_layer,
void (*hold)(struct cflayer *lyr),
void (*put)(struct cflayer *lyr));
/**
* caif_connect_req_to_link_param - Translate configuration parameters
* from socket format to internal format.
* @cnfg: Pointer to configuration handler
* @con_req: Configuration parameters supplied in function
* caif_connect_client
* @channel_setup_param: Parameters supplied to the CAIF Core stack for
* setting up channels.
*
*/

int caif_connect_req_to_link_param(struct cfcnfg *cnfg,
struct caif_connect_request *con_req,
struct cfctrl_link_param *setup_param);

/**
* caif_free_client - Free memory used to manage the client in the CAIF Stack.
*
Expand Down
71 changes: 8 additions & 63 deletions include/net/caif/cfcnfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ enum cfcnfg_phy_preference {
CFPHYPREF_LOOP
};

/**
* cfcnfg_create() - Get the CAIF configuration object given network.
* @net: Network for the CAIF configuration object.
*/
struct cfcnfg *get_cfcnfg(struct net *net);

/**
* cfcnfg_create() - Create the CAIF configuration object.
*/
Expand All @@ -65,17 +71,15 @@ void cfcnfg_remove(struct cfcnfg *cfg);
* @dev: Pointer to link layer device
* @phy_layer: Specify the physical layer. The transmit function
* MUST be set in the structure.
* @phyid: The assigned physical ID for this layer, used in
* cfcnfg_add_adapt_layer to specify PHY for the link.
* @pref: The phy (link layer) preference.
* @fcs: Specify if checksum is used in CAIF Framing Layer.
* @stx: Specify if Start Of Frame extension is used.
* @stx: Specify if Start Of Frame eXtention is used.
*/

void
cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
struct net_device *dev, struct cflayer *phy_layer,
u16 *phyid, enum cfcnfg_phy_preference pref,
enum cfcnfg_phy_preference pref,
bool fcs, bool stx);

/**
Expand All @@ -87,65 +91,6 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, enum cfcnfg_phy_type phy_type,
*/
int cfcnfg_del_phy_layer(struct cfcnfg *cnfg, struct cflayer *phy_layer);

/**
* cfcnfg_disconn_adapt_layer - Disconnects an adaptation layer.
*
* @cnfg: Pointer to a CAIF configuration object, created by
* cfcnfg_create().
* @adap_layer: Adaptation layer to be removed.
*/
int cfcnfg_disconn_adapt_layer(struct cfcnfg *cnfg,
struct cflayer *adap_layer);

/**
* cfcnfg_release_adap_layer - Used by client to release the adaptation layer.
*
* @adap_layer: Adaptation layer.
*/
void cfcnfg_release_adap_layer(struct cflayer *adap_layer);

/**
* cfcnfg_add_adaptation_layer - Add an adaptation layer to the CAIF stack.
*
* The adaptation Layer is where the interface to application or higher-level
* driver functionality is implemented.
*
* @cnfg: Pointer to a CAIF configuration object, created by
* cfcnfg_create().
* @param: Link setup parameters.
* @adap_layer: Specify the adaptation layer; the receive and
* flow-control functions MUST be set in the structure.
* @ifindex: Link layer interface index used for this connection.
* @proto_head: Protocol head-space needed by CAIF protocol,
* excluding link layer.
* @proto_tail: Protocol tail-space needed by CAIF protocol,
* excluding link layer.
*/
int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg,
struct cfctrl_link_param *param,
struct cflayer *adap_layer,
int *ifindex,
int *proto_head,
int *proto_tail);

/**
* cfcnfg_get_phyid() - Get physical ID, given type.
* Returns one of the physical interfaces matching the given type.
* Zero if no match is found.
* @cnfg: Configuration object
* @phy_pref: Caif Link Layer preference
*/
struct dev_info *cfcnfg_get_phyid(struct cfcnfg *cnfg,
enum cfcnfg_phy_preference phy_pref);

/**
* cfcnfg_get_id_from_ifi() - Get the Physical Identifier of ifindex,
* it matches caif physical id with the kernel interface id.
* @cnfg: Configuration object
* @ifi: ifindex obtained from socket.c bindtodevice.
*/
int cfcnfg_get_id_from_ifi(struct cfcnfg *cnfg, int ifi);

/**
* cfcnfg_set_phy_state() - Set the state of the physical interface device.
* @cnfg: Configuration object
Expand Down
2 changes: 1 addition & 1 deletion net/caif/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ caif-y := caif_dev.o \
cffrml.o cfveil.o cfdbgl.o\
cfserl.o cfdgml.o \
cfrfml.o cfvidl.o cfutill.o \
cfsrvl.o cfpkt_skbuff.o caif_config_util.o
cfsrvl.o cfpkt_skbuff.o

obj-$(CONFIG_CAIF) += caif.o
obj-$(CONFIG_CAIF_NETDEV) += chnl_net.o
Expand Down
99 changes: 0 additions & 99 deletions net/caif/caif_config_util.c

This file was deleted.

Loading

0 comments on commit bee925d

Please sign in to comment.