Beispiel #1
0
static void __exit pdp_cleanup(void)
{
	int slot;
	struct pdp_info *dev;

	down(&pdp_lock);
	for (slot = 0; slot < MAX_PDP_CONTEXT; slot++) {
		dev = pdp_remove_slot(slot);
		if (dev) {
			if (dev->type == DEV_TYPE_NET) {
				DPRINTK(1, "%s(id: %u) network device removed\n", 
					dev->vn_dev.net->name, dev->id);
				vnet_del_dev(dev->vn_dev.net);
			} else if (dev->type == DEV_TYPE_SERIAL) {
				struct tty_driver * tty_driver = get_tty_driver_by_id(dev);

					DPRINTK(1, "%s(id: %u) serial device removed\n",
						tty_driver->name, dev->id);

				vs_del_dev(dev);
			}

			vfree(dev);
		}
	}
	up(&pdp_lock);
}
Beispiel #2
0
static int pdp_deactivate(pdp_arg_t *pdp_arg, int force)
{
	struct pdp_info *dev = NULL;

   DPRINTK(2, "BEGIN\n");
	DPRINTK(1, "id: %d\n", pdp_arg->id);

	mutex_lock(&pdp_lock);

	if (pdp_arg->id == 1) {
		DPRINTK(1, "Channel ID is 1, we will remove the network device (pdp) of channel ID: %d.\n",
				pdp_arg->id + g_adjust);
	}

	else {
		DPRINTK(1, "Channel ID: %d\n", pdp_arg->id);
	}

	pdp_arg->id = pdp_arg->id + g_adjust;
	//pdp_arg->id += PDP_ID_ADJUST;
	DPRINTK(1, "ID is adjusted, new ID: %d\n", pdp_arg->id);

	dev = pdp_get_dev(pdp_arg->id);

	if (dev == NULL) {
		DPRINTK(1, "not found id: %d\n", pdp_arg->id);
		mutex_unlock(&pdp_lock);
		return -EINVAL;
	}
	if (!force && dev->flags & DEV_FLAG_STICKY) {
		DPRINTK(1, "sticky id: %u\n", pdp_arg->id);
		mutex_unlock(&pdp_lock);
		return -EACCES;
	}

	pdp_remove_dev(pdp_arg->id);
	mutex_unlock(&pdp_lock);

	if (dev->type == DEV_TYPE_NET) {
		DPRINTK(1, "%s(id: %u) network device removed\n", 
			dev->vn_dev.net->name, dev->id);
		vnet_del_dev(dev->vn_dev.net);
	} else if (dev->type == DEV_TYPE_SERIAL) {
		struct tty_driver * tty_driver = get_tty_driver_by_id(dev);

			DPRINTK(1, "%s(id: %u) serial device removed\n",
				tty_driver->name, dev->id);
		vs_del_dev(dev);
	}
	kfree(dev);
   DPRINTK(2, "END\n");
	return 0;
}
Beispiel #3
0
static int pdp_deactivate(struct pdp_arg *pdp_arg, int force)
{
	struct pdp_info *dev = NULL;

	down(&pdp_lock);
	pdp_arg->id = pdp_arg->id + g_adjust;
	DPRINTK(2, "ID is adjusted, new ID: %d\n", pdp_arg->id);

	dev = pdp_get_dev(pdp_arg->id);

	if (dev == NULL) {
		pr_err("[MULTIPDP] not found id: %u\n", pdp_arg->id);
		up(&pdp_lock);
		return -EINVAL;
	}
	if (!force && dev->flags & DEV_FLAG_STICKY) {
		pr_err("[MULTIPDP] sticky id: %u\n", pdp_arg->id);
		up(&pdp_lock);
		return -EACCES;
	}

	pdp_remove_dev(pdp_arg->id);
	up(&pdp_lock);

	if (dev->type == DEV_TYPE_NET) {
#ifdef	NO_TTY_MUTEX_VNET
		vnet_stop(dev->vn_dev.net);
		down(&pdp_txlock);
		pdp_net_activation_count--;
#endif
		vnet_del_dev(dev->vn_dev.net);
#ifdef	NO_TTY_MUTEX_VNET
		up(&pdp_txlock);
#endif

	} else if (dev->type == DEV_TYPE_SERIAL) {
		vs_del_dev(dev);
	}

	vfree(dev);
	return 0;
}
Beispiel #4
0
static void __exit pdp_cleanup(void)
{
	int slot;
	struct pdp_info *dev;

	down(&pdp_lock);
	for (slot = 0; slot < MAX_PDP_CONTEXT; slot++) {
		dev = pdp_remove_slot(slot);
		if (dev) {
			if (dev->type == DEV_TYPE_NET)
				vnet_del_dev(dev->vn_dev.net);
			else if (dev->type == DEV_TYPE_SERIAL)
				vs_del_dev(dev);
			else
				pr_err("[MULTIPDP] Invalid device type\n");

			vfree(dev);
		}
	}
	up(&pdp_lock);
}
Beispiel #5
0
static int pdp_deactivate(pdp_arg_t *pdp_arg, int force)
{
	struct pdp_info *dev = NULL;

	DPRINTK(1, "id: %d\n", pdp_arg->id);

	down(&pdp_lock);

	if (pdp_arg->id == 1) {
		DPRINTK(1, "Channel ID is 1, we will remove the network device (pdp) of channel ID: %d.\n",
				pdp_arg->id + g_adjust);
	}

	else {
		DPRINTK(1, "Channel ID: %d\n", pdp_arg->id);
	}

	pdp_arg->id = pdp_arg->id + g_adjust;
	//pdp_arg->id += PDP_ID_ADJUST;
	DPRINTK(1, "ID is adjusted, new ID: %d\n", pdp_arg->id);

	dev = pdp_get_dev(pdp_arg->id);

	if (dev == NULL) {
		DPRINTK(1, "not found id: %u\n", pdp_arg->id);
		up(&pdp_lock);
		return -EINVAL;
	}
	if (!force && dev->flags & DEV_FLAG_STICKY) {
		DPRINTK(1, "sticky id: %u\n", pdp_arg->id);
		up(&pdp_lock);
		return -EACCES;
	}

	pdp_remove_dev(pdp_arg->id);
	up(&pdp_lock);

	if (dev->type == DEV_TYPE_NET) {
#ifdef	NO_TTY_MUTEX_VNET
		//printk("<--- VNET Mutex lock : Before .. !!\n");
        vnet_stop(dev->vn_dev.net);
		down(&pdp_txlock);
		pdp_net_activation_count--;
		//printk("<--- VNET Mutex lock : After .. !!\n");
#endif
		DPRINTK(1, "%s(id: %u) network device removed\n", 
			dev->vn_dev.net->name, dev->id);
		vnet_del_dev(dev->vn_dev.net);
#ifdef	NO_TTY_MUTEX_VNET
		//printk("<--- VNET Mutex Unlock : Before .. !!\n");
		up(&pdp_txlock);
		//printk("<--- VNET Mutex Unlock : After .. !!\n");
#endif

	} else if (dev->type == DEV_TYPE_SERIAL) {
		struct tty_driver * tty_driver = get_tty_driver_by_id(dev);

			DPRINTK(1, "%s(id: %u) serial device removed\n",
				tty_driver->name, dev->id);
		vs_del_dev(dev);
	}

	vfree(dev);
	return 0;
}
Beispiel #6
0
static int pdp_activate(pdp_arg_t *pdp_arg, unsigned type, unsigned flags)
{
	int ret;
	struct pdp_info *dev;
	struct net_device *net;

	dev = vmalloc(sizeof(struct pdp_info) + MAX_PDP_PACKET_LEN);
	if (dev == NULL) {
		DPRINTK(1, "out of memory\n");
		return -ENOMEM;
	}
	memset(dev, 0, sizeof(struct pdp_info));

	/* @LDK@ added by gykim on 20070203 for adjusting IPC 3.0 spec. */
	if (type == DEV_TYPE_NET) {
		dev->id = pdp_arg->id + g_adjust;
	}

	else {
		dev->id = pdp_arg->id;
	}
	/* @LDK@ added by gykim on 20070203 for adjusting IPC 3.0 spec. */

	dev->type = type;
	dev->flags = flags;
	dev->tx_buf = (u8 *)(dev + 1);

	if (type == DEV_TYPE_NET) {
		net = vnet_add_dev((void *)dev);
		if (net == NULL) {
			vfree(dev);
			return -ENOMEM;
		}

		dev->vn_dev.net = net;
		strcpy(pdp_arg->ifname, net->name);

		down(&pdp_lock);
		ret = pdp_add_dev(dev);
		if (ret < 0) {
			EPRINTK("pdp_add_dev() failed\n");
			up(&pdp_lock);
			vnet_del_dev(dev->vn_dev.net);
			vfree(dev);
			return ret;
		}
		pdp_net_activation_count++;
		up(&pdp_lock);

		DPRINTK(1, "%s(id: %u) network device created\n", 
			net->name, dev->id);
	} else if (type == DEV_TYPE_SERIAL) {
		init_MUTEX(&dev->vs_dev.write_lock);
		strcpy(dev->vs_dev.tty_name, pdp_arg->ifname);

		ret = vs_add_dev(dev);
		if (ret < 0) {
			vfree(dev);
			return ret;
		}

		down(&pdp_lock);
		ret = pdp_add_dev(dev);
		if (ret < 0) {
			DPRINTK(1, "pdp_add_dev() failed\n");
			up(&pdp_lock);
			vs_del_dev(dev);
			vfree(dev);
			return ret;
		}
		up(&pdp_lock);

		{
			struct tty_driver * tty_driver = get_tty_driver_by_id(dev);

			DPRINTK(1, "%s(id: %u) serial device is created.\n",
					tty_driver->name, dev->id);
		}
	}

	return 0;
}
Beispiel #7
0
static int pdp_activate(struct pdp_arg *pdp_arg, unsigned type, unsigned flags)
{
	int ret;
	struct pdp_info *dev;
	struct net_device *net;

	dev = vmalloc(sizeof(struct pdp_info) + MAX_PDP_PACKET_LEN);
	if (dev == NULL) {
		pr_err("[MULTIPDP] out of memory\n");
		return -ENOMEM;
	}
	memset(dev, 0, sizeof(struct pdp_info));

	/* @LDK@ added by gykim on 20070203 for adjusting IPC 3.0 spec. */
	if (type == DEV_TYPE_NET)
		dev->id = pdp_arg->id + g_adjust;
	else
	    dev->id = pdp_arg->id;

	/* @LDK@ added by gykim on 20070203 for adjusting IPC 3.0 spec. */
	dev->type = type;
	dev->flags = flags;
	dev->tx_buf = (u8 *) (dev + 1);

	if (type == DEV_TYPE_NET) {
		net = vnet_add_dev((void *)dev);
		if (net == NULL) {
			pr_err("[MULTIPDP] vnet_add_dev is failed");
			vfree(dev);
			return -ENOMEM;
		}

		dev->vn_dev.net = net;

		strncpy(pdp_arg->ifname,
				net->name,
				APP_NAME_MAX_LEN);

		down(&pdp_lock);
		ret = pdp_add_dev(dev);
		if (ret < 0) {
			pr_err("[MULTIPDP] pdp_add_dev() failed\n");
			up(&pdp_lock);
			vnet_del_dev(dev->vn_dev.net);
			vfree(dev);
			return ret;
		}
		pdp_net_activation_count++;
		up(&pdp_lock);

		DPRINTK(2, "%s(id: %u) network device created\n",
			net->name, dev->id);
	} else if (type == DEV_TYPE_SERIAL) {
		init_MUTEX(&dev->vs_dev.write_lock);

		strncpy(dev->vs_dev.tty_name,
				pdp_arg->ifname,
				APP_NAME_MAX_LEN);

		ret = vs_add_dev(dev);
		if (ret < 0) {
			vfree(dev);
			return ret;
		}

		down(&pdp_lock);
		ret = pdp_add_dev(dev);
		if (ret < 0) {
			pr_err("[MULTIPDP] pdp_add_dev() failed\n");
			up(&pdp_lock);
			vs_del_dev(dev);
			vfree(dev);
			return ret;
		}
		up(&pdp_lock);
		DPRINTK(2, "serial device is created id[%u]\n",
				dev->id);
	}

	return 0;
}