Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2aa40aef authored by Sjur Braendeland's avatar Sjur Braendeland Committed by David S. Miller
Browse files

caif: Use link layer MTU instead of fixed MTU



Previously CAIF supported maximum transfer size of ~4050.
The transfer size is now calculated dynamically based on the
link layers mtu size.

Signed-off-by: default avatarSjur <Braendeland@stericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a7da1f55
Loading
Loading
Loading
Loading
+0 −1
Original line number Original line Diff line number Diff line
@@ -403,7 +403,6 @@ static void caifdev_setup(struct net_device *dev)
	dev->type = ARPHRD_CAIF;
	dev->type = ARPHRD_CAIF;
	dev->flags = IFF_POINTOPOINT | IFF_NOARP;
	dev->flags = IFF_POINTOPOINT | IFF_NOARP;
	dev->mtu = CAIF_MAX_MTU;
	dev->mtu = CAIF_MAX_MTU;
	dev->hard_header_len = CAIF_NEEDED_HEADROOM;
	dev->tx_queue_len = 0;
	dev->tx_queue_len = 0;
	dev->destructor = free_netdev;
	dev->destructor = free_netdev;
	skb_queue_head_init(&serdev->head);
	skb_queue_head_init(&serdev->head);
+6 −2
Original line number Original line Diff line number Diff line
@@ -50,6 +50,9 @@ struct caif_connect_request {
 * @client_layer:	User implementation of client layer. This layer
 * @client_layer:	User implementation of client layer. This layer
 *			MUST have receive and control callback functions
 *			MUST have receive and control callback functions
 *			implemented.
 *			implemented.
 * @ifindex:		Link layer interface index used for this connection.
 * @headroom:		Head room needed by CAIF protocol.
 * @tailroom:		Tail room needed by CAIF protocol.
 *
 *
 * This function connects a CAIF channel. The Client must implement
 * This function connects a CAIF channel. The Client must implement
 * the struct cflayer. This layer represents the Client layer and holds
 * the struct cflayer. This layer represents the Client layer and holds
@@ -59,8 +62,9 @@ struct caif_connect_request {
 * E.g. CAIF Socket will call this function for each socket it connects
 * E.g. CAIF Socket will call this function for each socket it connects
 * and have one client_layer instance for each socket.
 * and have one client_layer instance for each socket.
 */
 */
int caif_connect_client(struct caif_connect_request *config,
int caif_connect_client(struct caif_connect_request *conn_req,
			   struct cflayer *client_layer);
			struct cflayer *client_layer, int *ifindex,
			int *headroom, int *tailroom);


/**
/**
 * caif_disconnect_client - Disconnects a client from the CAIF stack.
 * caif_disconnect_client - Disconnects a client from the CAIF stack.
+0 −6
Original line number Original line Diff line number Diff line
@@ -15,14 +15,8 @@ struct cfpktq;
struct caif_payload_info;
struct caif_payload_info;
struct caif_packet_funcs;
struct caif_packet_funcs;


#define CAIF_MAX_FRAMESIZE 4096
#define CAIF_MAX_PAYLOAD_SIZE (4096 - 64)
#define CAIF_NEEDED_HEADROOM (10)
#define CAIF_NEEDED_TAILROOM (2)


#define CAIF_LAYER_NAME_SZ 16
#define CAIF_LAYER_NAME_SZ 16
#define CAIF_SUCCESS	1
#define CAIF_FAILURE	0


/**
/**
 * caif_assert() - Assert function for CAIF.
 * caif_assert() - Assert function for CAIF.
+12 −4
Original line number Original line Diff line number Diff line
@@ -7,6 +7,7 @@
#ifndef CFCNFG_H_
#ifndef CFCNFG_H_
#define CFCNFG_H_
#define CFCNFG_H_
#include <linux/spinlock.h>
#include <linux/spinlock.h>
#include <linux/netdevice.h>
#include <net/caif/caif_layer.h>
#include <net/caif/caif_layer.h>
#include <net/caif/cfctrl.h>
#include <net/caif/cfctrl.h>


@@ -73,8 +74,8 @@ void cfcnfg_remove(struct cfcnfg *cfg);


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


/**
/**
@@ -114,11 +115,18 @@ void cfcnfg_release_adap_layer(struct cflayer *adap_layer);
 * @param:		Link setup parameters.
 * @param:		Link setup parameters.
 * @adap_layer:		Specify the adaptation layer; the receive and
 * @adap_layer:		Specify the adaptation layer; the receive and
 *			flow-control functions MUST be set in the structure.
 *			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,
int cfcnfg_add_adaptation_layer(struct cfcnfg *cnfg,
			    struct cfctrl_link_param *param,
			    struct cfctrl_link_param *param,
			    struct cflayer *adap_layer);
			    struct cflayer *adap_layer,
			    int *ifindex,
			    int *proto_head,
			    int *proto_tail);


/**
/**
 * cfcnfg_get_phyid() - Get physical ID, given type.
 * cfcnfg_get_phyid() - Get physical ID, given type.
+8 −4
Original line number Original line Diff line number Diff line
@@ -255,7 +255,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
			pref = CFPHYPREF_HIGH_BW;
			pref = CFPHYPREF_HIGH_BW;
			break;
			break;
		}
		}

		dev_hold(dev);
		cfcnfg_add_phy_layer(get_caif_conf(),
		cfcnfg_add_phy_layer(get_caif_conf(),
				     phy_type,
				     phy_type,
				     dev,
				     dev,
@@ -285,6 +285,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
		caifd->layer.up->ctrlcmd(caifd->layer.up,
		caifd->layer.up->ctrlcmd(caifd->layer.up,
					 _CAIF_CTRLCMD_PHYIF_DOWN_IND,
					 _CAIF_CTRLCMD_PHYIF_DOWN_IND,
					 caifd->layer.id);
					 caifd->layer.id);
		might_sleep();
		res = wait_event_interruptible_timeout(caifd->event,
		res = wait_event_interruptible_timeout(caifd->event,
					atomic_read(&caifd->in_use) == 0,
					atomic_read(&caifd->in_use) == 0,
					TIMEOUT);
					TIMEOUT);
@@ -300,6 +301,7 @@ static int caif_device_notify(struct notifier_block *me, unsigned long what,
				   "Unregistering an active CAIF device: %s\n",
				   "Unregistering an active CAIF device: %s\n",
				   __func__, dev->name);
				   __func__, dev->name);
		cfcnfg_del_phy_layer(get_caif_conf(), &caifd->layer);
		cfcnfg_del_phy_layer(get_caif_conf(), &caifd->layer);
		dev_put(dev);
		atomic_set(&caifd->state, what);
		atomic_set(&caifd->state, what);
		break;
		break;


@@ -326,7 +328,8 @@ struct cfcnfg *get_caif_conf(void)
EXPORT_SYMBOL(get_caif_conf);
EXPORT_SYMBOL(get_caif_conf);


int caif_connect_client(struct caif_connect_request *conn_req,
int caif_connect_client(struct caif_connect_request *conn_req,
			   struct cflayer *client_layer)
			struct cflayer *client_layer, int *ifindex,
			int *headroom, int *tailroom)
{
{
	struct cfctrl_link_param param;
	struct cfctrl_link_param param;
	int ret;
	int ret;
@@ -334,8 +337,9 @@ int caif_connect_client(struct caif_connect_request *conn_req,
	if (ret)
	if (ret)
		return ret;
		return ret;
	/* Hook up the adaptation layer. */
	/* Hook up the adaptation layer. */
	return cfcnfg_add_adaptation_layer(get_caif_conf(),
	return cfcnfg_add_adaptation_layer(get_caif_conf(), &param,
						&param, client_layer);
					client_layer, ifindex,
					headroom, tailroom);
}
}
EXPORT_SYMBOL(caif_connect_client);
EXPORT_SYMBOL(caif_connect_client);


Loading