<commit_before>/**
 * @file
 * @brief  Entry net for pnet version network subsystem.
 *
 * @date 27.10.11
 * @author <NAME>
 */

#include <errno.h>
#include <embox/unit.h>
#include <mem/objalloc.h>

#include <linux/interrupt.h>

#include <pnet/prior_path.h>
#include <pnet/core.h>
#include <pnet/node.h>
#include <pnet/repo.h>
#include <pnet/pnet_pack.h>


EMBOX_UNIT_INIT(unit_init);

struct pack {
	struct list_head link;
	void *data;
};

OBJALLOC_DEF(common_pool, struct pack, OPTION_GET(NUMBER,rx_queue_size));

static LIST_HEAD(pnet_queue);

static void pnetif_rx_schedule(struct pack *pack) {
	list_add_tail(&pnet_queue, &pack->link);
	raise_softirq(PNET_RX_SOFTIRQ);
}

int netif_rx(void *data) {
	struct pack *pack;

	if (NULL == data) {
		return NET_RX_DROP;
	}

	pack = objalloc(&common_pool);
	INIT_LIST_HEAD(&pack->link);
	pack->data = data;

	pnetif_rx_schedule(pack);

	return NET_RX_SUCCESS;
}

static void pnet_rx_action(softirq_nr_t nr, void *data) {
	struct pack *pack, *safe;
	uint32_t type;
	struct pnet_pack *skb_pack;
	net_node_t entry = pnet_get_module("pnet entry");

	list_for_each_entry_safe(pack, safe, &pnet_queue, link) {
		type = *(uint32_t*) pack->data;

		if ((type & 3)  == NET_TYPE) {
			skb_pack = pnet_pack_create(pack->data, 0, NET_TYPE);

			skb_pack->node = entry;

			pnet_entry(skb_pack);
		} else {
			pnet_entry((struct pnet_pack*) pack->data);
		}

		list_del(&pack->link);
		pool_free(&common_pool, pack);
	}
}<commit_msg>pnet net_entry proper packet queueing, early packet removing from list<commit_after>/**
 * @file
 * @brief  Entry net for pnet version network subsystem.
 *
 * @date 27.10.11
 * @author <NAME>
 */

#include <errno.h>
#include <embox/unit.h>
#include <mem/objalloc.h>

#include <linux/interrupt.h>

#include <pnet/prior_path.h>
#include <pnet/core.h>
#include <pnet/node.h>
#include <pnet/repo.h>
#include <pnet/pnet_pack.h>

EMBOX_UNIT_INIT(unit_init);

struct pack {
	struct list_head link;
	void *data;
};

OBJALLOC_DEF(common_pool, struct pack, OPTION_GET(NUMBER,rx_queue_size));

static LIST_HEAD(pnet_queue);

static void pnetif_rx_schedule(struct pack *pack) {
	list_add_tail(&pack->link,&pnet_queue);
	softirq_raise(PNET_RX_SOFTIRQ);
}

int netif_rx(void *data) {
	struct pack *pack;

	if (NULL == data) {
		return NET_RX_DROP;
	}

	if (!(pack = objalloc(&common_pool))) {
		return -ENOMEM;
	}

	INIT_LIST_HEAD(&pack->link);
	pack->data = data;

	pnetif_rx_schedule(pack);
	return NET_RX_SUCCESS;
}

static void pnet_rx_action(softirq_nr_t nr, void *data) {
	struct pack *pack, *safe;
	uint32_t type;
	struct pnet_pack *skb_pack;
	net_node_t entry = pnet_get_module("pnet entry");

	list_for_each_entry_safe(pack, safe, &pnet_queue, link) {
		void *pack_data = pack->data;
		list_del(&pack->link);
		objfree(&common_pool, pack);
		type = *(uint32_t*) pack_data;

		if ((type & 3)  == NET_TYPE) {
			skb_pack = pnet_pack_create(pack_data, 0, NET_TYPE);

			skb_pack->node = entry;

			pnet_entry(skb_pack);
		} else {
			pnet_entry((struct pnet_pack*) pack_data);
		}

	}
}
{'fraction_non_alphanumeric': 0.1437951411687459, 'fraction_numerical': 0.007879185817465528, 'mean_word_length': 4.870905587668593, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2057247', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1232, 'n_words': 248}