Ejemplo n.º 1
0
static int __init kudp_init(void)
{
	netlink_sock = netlink_kernel_create(&init_net, NETLINK_USERSOCK, 0,udp_receive, NULL, THIS_MODULE);
	return 0;
}
Ejemplo n.º 2
0
/**
 * \fn     wlanDrvIf_Create
 * \brief  Create the driver instance
 *
 * Allocate driver object.
 * Initialize driver OS resources (IRQ, workqueue, events socket)
 * Setup driver network interface.
 * Create and link all driver modules.
 *
 * \note
 * \param  void
 * \return 0 - OK, else - failure
 * \sa     wlanDrvIf_Destroy
 */
static int wlanDrvIf_Create (void)
{
    TWlanDrvIfObj *drv;
    int rc;

    /* Allocate driver's structure */
    drv = kmalloc (sizeof(TWlanDrvIfObj), GFP_KERNEL);
    if (!drv)
    {
        return -ENOMEM;
    }

#ifdef TI_DBG
    tb_init(TB_OPTION_NONE);
#endif
    pDrvStaticHandle = drv;  /* save for module destroy */
#ifdef TI_MEM_ALLOC_TRACE
    os_printf ("MTT:%s:%d ::kmalloc(%lu, %x) : %lu\n", __FUNCTION__, __LINE__, sizeof(TWlanDrvIfObj), GFP_KERNEL, sizeof(TWlanDrvIfObj));
#endif
    memset (drv, 0, sizeof(TWlanDrvIfObj));

    drv->bSuspendInProgress = TI_FALSE;

    drv->tCommon.eDriverState = DRV_STATE_IDLE;
#ifdef AP_MODE_ENABLED
    /* for STA role, need to allocate another driver and to set STA role */
    drv->tCommon.eIfRole = IF_ROLE_TYPE_AP;
#endif

    drv->pWorkQueue = create_freezeable_workqueue(TIWLAN_WQ_NAME);
    if (!drv->pWorkQueue)
    {
		ti_dprintf (TIWLAN_LOG_ERROR, "wlanDrvIf_Create(): Failed to create workQ!\n");
		rc = -EINVAL;
		goto drv_create_end_1;
    }

    drv->wl_packet = 0;
    drv->wl_count = 0;
#ifdef CONFIG_HAS_WAKELOCK
    wake_lock_init (&drv->wl_wifi, WAKE_LOCK_SUSPEND, "wifi_wake");
    wake_lock_init (&drv->wl_rxwake, WAKE_LOCK_SUSPEND, "wifi_rx_wake");
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
    INIT_WORK(&drv->tWork, wlanDrvIf_DriverTask, (void *)drv);
#else
    INIT_WORK(&drv->tWork, wlanDrvIf_DriverTask);
#endif
    spin_lock_init (&drv->lock);

    /* Setup driver network interface. */
    rc = wlanDrvIf_SetupNetif (drv);
    if (rc)
    {
		goto drv_create_end_2;
    }


    /* Create the events socket interface */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
    drv->wl_sock = netlink_kernel_create( NETLINK_USERSOCK, 0, NULL, THIS_MODULE );
#else
    drv->wl_sock = netlink_kernel_create(&init_net, NETLINK_USERSOCK, 0, NULL, NULL, THIS_MODULE );
#endif
    if (drv->wl_sock == NULL)
    {
        ti_dprintf (TIWLAN_LOG_ERROR, "netlink_kernel_create() failed !\n");
		rc = -EINVAL;
		goto drv_create_end_3;
    }

    /* Create all driver modules and link their handles */
	rc = drvMain_Create (drv,
                         &drv->tCommon.hDrvMain,
                         &drv->tCommon.hCmdHndlr,
                         &drv->tCommon.hContext,
                         &drv->tCommon.hTxDataQ,
                         &drv->tCommon.hTxMgmtQ,
                         &drv->tCommon.hTxCtrl,
                         &drv->tCommon.hTWD,
                         &drv->tCommon.hEvHandler,
                         &drv->tCommon.hCmdDispatch,
                         &drv->tCommon.hReport);
    if (rc != TI_OK)
    {
        ti_dprintf (TIWLAN_LOG_ERROR, "%s: Failed to dvrMain_Create!\n", __func__);
        rc = -EINVAL;
        goto drv_create_end_4;
    }
    /*
     *  Initialize interrupts (or polling mode for debug):
     */
#ifdef PRIODIC_INTERRUPT
    /* Debug mode: Polling (the timer is started by HwInit process) */
    drv->hPollTimer = os_timerCreate ((TI_HANDLE)drv, wlanDrvIf_PollIrqHandler, (TI_HANDLE)drv);
#else
    /* Normal mode: Interrupts (the default mode) */
    rc = hPlatform_initInterrupt (drv, (void*)wlanDrvIf_HandleInterrupt);
    if (rc)
    {
        ti_dprintf (TIWLAN_LOG_ERROR, "wlanDrvIf_Create(): Failed to register interrupt handler!\n");
		goto drv_create_end_5;
    }
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
    set_irq_type (drv->irq, IRQT_FALLING);
#endif
#endif  /* PRIODIC_INTERRUPT */

    return 0;
drv_create_end_5:
	if (drv->tCommon.hDrvMain) 
    {
		drvMain_Destroy (drv->tCommon.hDrvMain);
	}

drv_create_end_4:
	if (drv->wl_sock) 
    {
		sock_release (drv->wl_sock->sk_socket);
	}

drv_create_end_3:
	if (drv->netdev) 
    {
		unregister_netdev (drv->netdev);
		free_netdev (drv->netdev);
	}

drv_create_end_2:
#ifdef CONFIG_HAS_WAKELOCK
	wake_lock_destroy (&drv->wl_wifi);
	wake_lock_destroy (&drv->wl_rxwake);
#endif

	if (drv->pWorkQueue)
    {
		destroy_workqueue (drv->pWorkQueue);
    }

drv_create_end_1:
	kfree (drv);
	printk ("%s: Fail, rc = %d\n", __func__, rc);
	return rc;
}
Ejemplo n.º 3
0
void create_permission_socket(void) {
	per_sock = netlink_kernel_create(&init_net, NETLINK_PERMISSON_TYPE, 0, msg_receive, NULL, THIS_MODULE);
	if (!per_sock) {
		printk(KERN_ERR "can not create a netlink socket.");
	}
}
Ejemplo n.º 4
0
/**
 * \fn     wlanDrvIf_Create
 * \brief  Create the driver instance
 *
 * Allocate driver object.
 * Initialize driver OS resources (IRQ, workqueue, events socket)
 * Setup driver network interface.
 * Create and link all driver modules.
 *
 * \note
 * \param  void
 * \return 0 - OK, else - failure
 * \sa     wlanDrvIf_Destroy
 */
static int wlanDrvIf_Create (void)
{
	TWlanDrvIfObj *drv;
	int rc;

	/* Allocate driver's structure */
	drv = kmalloc (sizeof(TWlanDrvIfObj), GFP_KERNEL);
	if (!drv)
	{
		return -ENOMEM;
	}
#ifdef TI_DBG
	tb_init(TB_OPTION_NONE);
#endif
	pDrvStaticHandle = drv;  /* save for module destroy */
#ifdef TI_MEM_ALLOC_TRACE
	os_printf ("MTT:%s:%d ::kmalloc(%lu, %x) : %lu\n", __FUNCTION__, __LINE__, sizeof(TWlanDrvIfObj), GFP_KERNEL, sizeof(TWlanDrvIfObj));
#endif
	memset (drv, 0, sizeof(TWlanDrvIfObj));

	drv->tCommon.eDriverState = DRV_STATE_IDLE;

	drv->pWorkQueue = create_singlethread_workqueue(TIWLAN_WQ_NAME);
	if (!drv->pWorkQueue)
	{
		return -ENOMEM;
	}

	drv->wl_packet = 0;
	drv->wl_count = 0;
#ifdef CONFIG_HAS_WAKELOCK
	wake_lock_init(&drv->wl_wifi, WAKE_LOCK_SUSPEND, "wifi_wake");
	wake_lock_init(&drv->wl_rxwake, WAKE_LOCK_SUSPEND, "wifi_rx_wake");
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
	INIT_WORK(&drv->tWork, wlanDrvIf_DriverTask, (void *)drv);
#else
	INIT_WORK(&drv->tWork, wlanDrvIf_DriverTask);
#endif
	spin_lock_init (&drv->lock);

	/* Setup driver network interface. */
	rc = wlanDrvIf_SetupNetif (drv);
	if (rc)
	{
		kfree (drv);
		return rc;
	}


	/* Create the events socket interface */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
	drv->wl_sock = netlink_kernel_create( NETLINK_USERSOCK, 0, NULL, THIS_MODULE );
#else
	drv->wl_sock = netlink_kernel_create(&init_net, NETLINK_USERSOCK, 0, NULL, NULL, THIS_MODULE );
#endif
	if (drv->wl_sock == NULL)
	{
		ti_dprintf (TIWLAN_LOG_ERROR, "netlink_kernel_create() failed !\n");
		return -EINVAL;
	}

	/* Create all driver modules and link their handles */
	drvMain_Create (drv,
	                &drv->tCommon.hDrvMain,
	                &drv->tCommon.hCmdHndlr,
	                &drv->tCommon.hContext,
	                &drv->tCommon.hTxDataQ,
	                &drv->tCommon.hTxMgmtQ,
	                &drv->tCommon.hTxCtrl,
	                &drv->tCommon.hTWD,
	                &drv->tCommon.hEvHandler,
	                &drv->tCommon.hCmdDispatch,
	                &drv->tCommon.hReport);

	/*
	 *  Initialize interrupts (or polling mode for debug):
	 */
#ifdef PRIODIC_INTERRUPT
	/* Debug mode: Polling (the timer is started by HwInit process) */
	drv->hPollTimer = os_timerCreate ((TI_HANDLE)drv, wlanDrvIf_PollIrqHandler, (TI_HANDLE)drv);
#else
	/* Normal mode: Interrupts (the default mode) */
	rc = hPlatform_initInterrupt (drv, (void*)wlanDrvIf_HandleInterrupt);
	if (rc)
	{
		ti_dprintf (TIWLAN_LOG_ERROR, "wlanDrvIf_Create(): Failed to register interrupt handler!\n");
		return rc;
	}
#endif  /* PRIODIC_INTERRUPT */

#ifdef CONFIG_PM
	/* register PM hooks in our SDIO driver */
	sdioDrv_register_pm(wlanDrvIf_Resume, wlanDrvIf_Suspend);
#endif


	return 0;
}
Ejemplo n.º 5
0
static struct sock *_rmnet_config_start_netlink(void)
{
	return netlink_kernel_create(&init_net,
				     RMNET_NETLINK_PROTO,
				     &rmnet_netlink_cfg);
}
int shrm_protocol_init(struct shrm_dev *shrm,
			received_msg_handler common_rx_handler,
			received_msg_handler audio_rx_handler)
{
	int err;

	shm_dev = shrm;
	boot_state = BOOT_INIT;
	dev_info(shrm->dev, "IPC_ISA BOOT_INIT\n");
	rx_common_handler = common_rx_handler;
	rx_audio_handler = audio_rx_handler;
	atomic_set(&ac_sleep_disable_count, 0);

	is_earlydrop = cpu_is_u8500ed();
	if (is_earlydrop != 0x01) {
		hrtimer_init(&timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
		timer.function = callback;
	}

	hrtimer_init(&mod_stuck_timer_0, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	mod_stuck_timer_0.function = shm_mod_stuck_timeout;
	hrtimer_init(&mod_stuck_timer_1, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	mod_stuck_timer_1.function = shm_mod_stuck_timeout;
	hrtimer_init(&fifo_full_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	fifo_full_timer.function = shm_fifo_full_timeout;

	shrm->shm_common_ch_wr_wq = create_singlethread_workqueue
		("shm_common_channel_irq");
	if (!shrm->shm_common_ch_wr_wq) {
		dev_err(shrm->dev, "failed to create work queue\n");
		return -ENOMEM;
	}
	shrm->shm_audio_ch_wr_wq = create_rt_workqueue
	  ("shm_audio_channel_irq");
	if (!shrm->shm_audio_ch_wr_wq) {
		dev_err(shrm->dev, "failed to create work queue\n");
		err = -ENOMEM;
		goto free_wq1;
	}
	shrm->shm_ac_wake_wq = create_rt_workqueue("shm_ac_wake_req");
	if (!shrm->shm_ac_wake_wq) {
		dev_err(shrm->dev, "failed to create work queue\n");
		err = -ENOMEM;
		goto free_wq2;
	}
	shrm->shm_ca_wake_wq = create_rt_workqueue("shm_ca_wake_req");
	if (!shrm->shm_ca_wake_wq) {
		dev_err(shrm->dev, "failed to create work queue\n");
		err = -ENOMEM;
		goto free_wq3;
	}
	shrm->shm_ac_sleep_wq = create_singlethread_workqueue
						("shm_ac_sleep_req");
	if (!shrm->shm_ac_sleep_wq) {
		dev_err(shrm->dev, "failed to create work queue\n");
		err = -ENOMEM;
		goto free_wq4;
	}
	shrm->shm_mod_stuck_wq = create_rt_workqueue("shm_mod_reset_req");
	if (!shrm->shm_mod_stuck_wq) {
		dev_err(shrm->dev, "failed to create work queue\n");
		err = -ENOMEM;
		goto free_wq5;
	}
	INIT_WORK(&shrm->send_ac_msg_pend_notify_0,
			send_ac_msg_pend_notify_0_work);
	INIT_WORK(&shrm->send_ac_msg_pend_notify_1,
			send_ac_msg_pend_notify_1_work);
	INIT_WORK(&shrm->shm_ca_wake_req, shm_ca_wake_req_work);
	INIT_WORK(&shrm->shm_ca_sleep_req, shm_ca_sleep_req_work);
	INIT_WORK(&shrm->shm_ac_sleep_req, shm_ac_sleep_req_work);
	INIT_WORK(&shrm->shm_ac_wake_req, shm_ac_wake_req_work);
	INIT_WORK(&shrm->shm_mod_reset_req, shm_mod_reset_work);

	/* set tasklet data */
	shm_ca_0_tasklet.data = (unsigned long)shrm;
	shm_ca_1_tasklet.data = (unsigned long)shrm;

	err = request_irq(IRQ_PRCMU_CA_SLEEP, shrm_prcmu_irq_handler,
			IRQF_NO_SUSPEND, "ca-sleep", shrm);
	if (err < 0) {
		dev_err(shm_dev->dev, "Failed alloc IRQ_PRCMU_CA_SLEEP.\n");
		goto free_wq6;
	}

	err = request_irq(IRQ_PRCMU_CA_WAKE, shrm_prcmu_irq_handler,
		IRQF_NO_SUSPEND, "ca-wake", shrm);
	if (err < 0) {
		dev_err(shm_dev->dev, "Failed alloc IRQ_PRCMU_CA_WAKE.\n");
		goto drop2;
	}

	err = request_irq(IRQ_PRCMU_MODEM_SW_RESET_REQ, shrm_prcmu_irq_handler,
			IRQF_NO_SUSPEND, "modem-sw-reset-req", shrm);
	if (err < 0) {
		dev_err(shm_dev->dev,
				"Failed alloc IRQ_PRCMU_MODEM_SW_RESET_REQ.\n");
		goto drop1;
	}

#ifdef CONFIG_U8500_SHRM_MODEM_SILENT_RESET
	/* init netlink socket for user-space communication */
	shrm_nl_sk = netlink_kernel_create(NULL, NETLINK_SHRM, 1,
			shm_nl_receive, NULL, THIS_MODULE);

	if (!shrm_nl_sk) {
		dev_err(shm_dev->dev, "netlink socket creation failed\n");
		goto drop;
	}
#endif

	return 0;

#ifdef CONFIG_U8500_SHRM_MODEM_SILENT_RESET
drop:
	free_irq(IRQ_PRCMU_MODEM_SW_RESET_REQ, NULL);
#endif
drop1:
	free_irq(IRQ_PRCMU_CA_WAKE, NULL);
drop2:
	free_irq(IRQ_PRCMU_CA_SLEEP, NULL);
free_wq6:
	destroy_workqueue(shrm->shm_mod_stuck_wq);
free_wq5:
	destroy_workqueue(shrm->shm_ac_sleep_wq);
free_wq4:
	destroy_workqueue(shrm->shm_ca_wake_wq);
free_wq3:
	destroy_workqueue(shrm->shm_ac_wake_wq);
free_wq2:
	destroy_workqueue(shrm->shm_audio_ch_wr_wq);
free_wq1:
	destroy_workqueue(shrm->shm_common_ch_wr_wq);
	return err;
}
Ejemplo n.º 7
0
static void ipt_logfn(unsigned int hooknum,
		      const struct sk_buff *skb,
		      const struct net_device *in,
		      const struct net_device *out,
		      const char *prefix)
{
	struct ipt_ulog_info loginfo = { 
		.nl_group = ULOG_DEFAULT_NLGROUP,
		.copy_range = 0,
		.qthreshold = ULOG_DEFAULT_QTHRESHOLD,
		.prefix = ""
	};

	ipt_ulog_packet(hooknum, skb, in, out, &loginfo, prefix);
}

static int ipt_ulog_checkentry(const char *tablename,
			       const struct ipt_entry *e,
			       void *targinfo,
			       unsigned int targinfosize,
			       unsigned int hookmask)
{
	struct ipt_ulog_info *loginfo = (struct ipt_ulog_info *) targinfo;

	if (targinfosize != IPT_ALIGN(sizeof(struct ipt_ulog_info))) {
		DEBUGP("ipt_ULOG: targinfosize %u != 0\n", targinfosize);
		return 0;
	}

	if (loginfo->prefix[sizeof(loginfo->prefix) - 1] != '\0') {
		DEBUGP("ipt_ULOG: prefix term %i\n",
		       loginfo->prefix[sizeof(loginfo->prefix) - 1]);
		return 0;
	}

	if (loginfo->qthreshold > ULOG_MAX_QLEN) {
		DEBUGP("ipt_ULOG: queue threshold %i > MAX_QLEN\n",
			loginfo->qthreshold);
		return 0;
	}

	return 1;
}

static struct ipt_target ipt_ulog_reg = {
	.name		= "ULOG",
	.target		= ipt_ulog_target,
	.checkentry	= ipt_ulog_checkentry,
	.me		= THIS_MODULE,
};

static int __init init(void)
{
	int i;

	DEBUGP("ipt_ULOG: init module\n");

	if (nlbufsiz >= 128*1024) {
		printk("Netlink buffer has to be <= 128kB\n");
		return -EINVAL;
	}

	/* initialize ulog_buffers */
	for (i = 0; i < ULOG_MAXNLGROUPS; i++) {
		init_timer(&ulog_buffers[i].timer);
		ulog_buffers[i].timer.function = ulog_timer;
		ulog_buffers[i].timer.data = i;
	}

	nflognl = netlink_kernel_create(NETLINK_NFLOG, NULL);
	if (!nflognl)
		return -ENOMEM;

	if (ipt_register_target(&ipt_ulog_reg) != 0) {
		sock_release(nflognl->sk_socket);
		return -EINVAL;
	}
	if (nflog)
		nf_log_register(PF_INET, &ipt_logfn);
	
	return 0;
}

static void __exit fini(void)
{
	ulog_buff_t *ub;
	int i;

	DEBUGP("ipt_ULOG: cleanup_module\n");

	if (nflog)
		nf_log_unregister(PF_INET, &ipt_logfn);
	ipt_unregister_target(&ipt_ulog_reg);
	sock_release(nflognl->sk_socket);

	/* remove pending timers and free allocated skb's */
	for (i = 0; i < ULOG_MAXNLGROUPS; i++) {
		ub = &ulog_buffers[i];
		if (timer_pending(&ub->timer)) {
			DEBUGP("timer was pending, deleting\n");
			del_timer(&ub->timer);
		}

		if (ub->skb) {
			kfree_skb(ub->skb);
			ub->skb = NULL;
		}
	}

}
Ejemplo n.º 8
0
int sdio_netlink_register(void)
{
	netlink_sock = netlink_kernel_create(&init_net, NETLINK_USERSOCK, 0, udp_receive, NULL, THIS_MODULE);
	return 0;
}