/*
* Copyright (C) ST-Ericsson AB 2010
* Author: Sjur Brendeland sjur.brandeland@stericsson.com
* Per Sigmond per.sigmond@stericsson.com
* License terms: GNU General Public License (GPL) version 2
*/
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/spinlock.h>
#include <linux/mutex.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <linux/poll.h>
#include <linux/tcp.h>
#include <linux/uaccess.h>
#include <asm/atomic.h>
#include <linux/caif/caif_socket.h>
#include <net/caif/caif_layer.h>
#include <net/caif/caif_dev.h>
#include <net/caif/cfpkt.h>
MODULE_LICENSE("GPL");
#define CHNL_SKT_READ_QUEUE_HIGH 200
#define CHNL_SKT_READ_QUEUE_LOW 100
static int caif_sockbuf_size = 40000;
static atomic_t caif_nr_socks = ATOMIC_INIT(0);
#define CONN_STATE_OPEN_BIT 1
#define CONN_STATE_PENDING_BIT 2
#define CONN_STATE_PEND_DESTROY_BIT 3
#define CONN_REMOTE_SHUTDOWN_BIT 4
#define TX_FLOW_ON_BIT 1
#define RX_FLOW_ON_BIT 2
#define STATE_IS_OPEN(cf_sk) test_bit(CONN_STATE_OPEN_BIT,\
(void *) &(cf_sk)->conn_state)
#define STATE_IS_REMOTE_SHUTDOWN(cf_sk) test_bit(CONN_REMOTE_SHUTDOWN_BIT,\
(void *) &(cf_sk)->conn_state)
#define STATE_IS_PENDING(cf_sk) test_bit(CONN_STATE_PENDING_BIT,\
(void *) &(cf_sk)->conn_state)
#define STATE_IS_PENDING_DESTROY(cf_sk) test_bit(CONN_STATE_PEND_DESTROY_BIT,\
(void *) &(cf_sk)->conn_state)
#define SET_STATE_PENDING_DESTROY(cf_sk) set_bit(CONN_STATE_PEND_DESTROY_BIT,\
(void *) &(cf_sk)->conn_state)
#define SET_STATE_OPEN(cf_sk) set_bit(CONN_STATE_OPEN_BIT,\
(void *) &(cf_sk)->conn_state)
#define SET_STATE_CLOSED(cf_sk) clear_bit(CONN_STATE_OPEN_BIT,\
(void *) &(cf_sk)->conn_state)
#define SET_PENDING_ON(cf_sk) set_bit(CONN_STATE_PENDING_BIT,\
(void *) &(cf_sk)->conn_state)
#define SET_PENDING_OFF(cf_sk) clear_bit(CONN_STATE_PENDING_BIT,\
(void *) &(cf_sk)->conn_state)
#define SET_REMOTE_SHUTDOWN(cf_sk) set_bit(CONN_REMOTE_SHUTDOWN_BIT,\
(void *) &(cf_sk)->conn_state)
#define SET_REMOTE_SHUTDOWN_OFF(dev) clear_bit(CONN_REMOTE_SHUTDOWN_BIT,\
(void *) &(dev)->conn_state)
#define RX_FLOW_IS_ON(cf_sk) test_bit(RX_FLOW_ON_BIT,\
(void *) &(cf_sk)->flow_state)
#define TX_FLOW_IS_ON(cf_sk) test_bit(TX_FLOW_ON_BIT,\
(void *) &(cf_sk)->flow_state)
#define SET_RX_FLOW_OFF(cf_sk) clear_bit(RX_FLOW_ON_BIT,\
(void *) &(cf_sk)->flow_state)
#define SET_RX_FLOW_ON(cf_sk) set_bit(RX_FLOW_ON_BIT,\
(void *) &(cf_sk)->flow_state)
#define SET_TX_FLOW_OFF(cf_sk) clear_bit(TX_FLOW_ON_BIT,\
(void *) &(cf_sk)->flow_state)
#define SET_TX_FLOW_ON(cf_sk) set_bit(TX_FLOW_ON_BIT,\
(void *) &(cf_sk)->flow_state)
#define SKT_READ_FLAG 0x01
#define SKT_WRITE_FLAG 0x02
static struct dentry *debugfsdir;
#include <linux/debugfs.h>
#ifdef CONFIG_DEBUG_FS
struct debug_fs_counter {
atomic_t num_open;
atomic_t num_close;
atomic_t num_init;
atomic_t num_init_resp;
atomic_t num_init_fail_resp;
atomic_t num_deinit;
atomic_t num_deinit_resp;
atomic_t num_remote_shutdown_ind;
atomic_t num_tx_flow_off_ind;
atomic_t num_tx_flow_on_ind;
atomic_t num_rx_flow_off;
atomic_t num_rx_flow_on;
atomic_t skb_in_use;
atomic_t skb_alloc;
atomic_t skb_free;
};
static