diff options
| author | Qiuwen Lu <[email protected]> | 2016-10-26 11:23:39 +0800 |
|---|---|---|
| committer | Qiuwen Lu <[email protected]> | 2016-10-26 11:23:39 +0800 |
| commit | 04a6cd715d9f6b884d18b9242b5065ef5b0348e3 (patch) | |
| tree | 28b5705df7e618543e42356aae3b38bd5d2eaa52 | |
| parent | 287e3ee0fc3ea5256cd33aef0d7c5d2487b841cf (diff) | |
完成协议栈入站侧框架性函数
| -rw-r--r-- | stack/include/sk_protocol_arp.h | 8 | ||||
| -rw-r--r-- | stack/include/sk_protocol_icmp.h | 6 | ||||
| -rw-r--r-- | stack/include/sk_protocol_tcp.h | 4 | ||||
| -rw-r--r-- | stack/include/sk_protocol_udp.h | 4 | ||||
| -rw-r--r-- | stack/src/device.c | 3 | ||||
| -rw-r--r-- | stack/src/protocol-arp.c (renamed from stack/src/arp.c) | 9 | ||||
| -rw-r--r-- | stack/src/protocol-icmp.c | 9 | ||||
| -rw-r--r-- | stack/src/protocol-tcp.c | 8 | ||||
| -rw-r--r-- | stack/src/protocol-udp.c | 9 | ||||
| -rw-r--r-- | stack/src/rxtx.c | 82 | ||||
| -rw-r--r-- | stack/src/udp.c | 0 |
11 files changed, 130 insertions, 12 deletions
diff --git a/stack/include/sk_protocol_arp.h b/stack/include/sk_protocol_arp.h index 718a43c..fd20284 100644 --- a/stack/include/sk_protocol_arp.h +++ b/stack/include/sk_protocol_arp.h @@ -18,9 +18,5 @@ int protocol_arp_slave_dev_init(struct sk_dev_desc * dev); int protocol_arp_slave_dev_deinit(struct sk_dev_desc * dev);
-// ARP���Ĵ�����ں�����������̴�����
-int protocol_arp_entry(struct stack_dev_handle * dev_handle,
- struct rte_mbuf * in_pkt[], struct rte_mbuf * out_pkt[],
- unsigned int nr_in_pkt, unsigned int * nr_left_pkt);
-
-int protocol_arp_request_send(struct sk_dev_desc * dev, struct in_addr in_addr);
\ No newline at end of file +void protocol_serv_arp_entry(struct sk_dev_desc* dev_desc,
+ thread_id_t sid, struct rte_mbuf* mbufs_in[], int nr_mbufs_in);
\ No newline at end of file diff --git a/stack/include/sk_protocol_icmp.h b/stack/include/sk_protocol_icmp.h new file mode 100644 index 0000000..11790ca --- /dev/null +++ b/stack/include/sk_protocol_icmp.h @@ -0,0 +1,6 @@ +#pragma once
+
+#include <mr_common.h>
+
+void protocol_serv_icmp_entry(struct sk_dev_desc* dev_desc, thread_id_t sid,
+ struct rte_mbuf* mbufs_in[], int nr_mbufs_in);
diff --git a/stack/include/sk_protocol_tcp.h b/stack/include/sk_protocol_tcp.h new file mode 100644 index 0000000..fb24bb2 --- /dev/null +++ b/stack/include/sk_protocol_tcp.h @@ -0,0 +1,4 @@ +#pragma once
+
+void protocol_serv_tcp_entry(struct sk_dev_desc* dev_desc, thread_id_t sid,
+ struct rte_mbuf* mbufs_in[], int nr_mbufs_in);
\ No newline at end of file diff --git a/stack/include/sk_protocol_udp.h b/stack/include/sk_protocol_udp.h new file mode 100644 index 0000000..c416278 --- /dev/null +++ b/stack/include/sk_protocol_udp.h @@ -0,0 +1,4 @@ +#pragma once
+
+void protocol_serv_udp_entry(struct sk_dev_desc* dev_desc,
+ thread_id_t sid, struct rte_mbuf* mbufs_in[], int nr_mbufs_in);
\ No newline at end of file diff --git a/stack/src/device.c b/stack/src/device.c index 9b04d62..bff5a05 100644 --- a/stack/src/device.c +++ b/stack/src/device.c @@ -160,6 +160,9 @@ static void sk_dev_desc_delete(struct sk_dev_desc * dev_desc) if (dev_desc->tx_loop_buffer[i] != NULL) rte_ring_free(dev_desc->tx_loop_buffer[i]); } + + rte_free(dev_desc); + return; } /* 以下为内部初始化、注销处理流程。*/ diff --git a/stack/src/arp.c b/stack/src/protocol-arp.c index 34131b8..8c4c046 100644 --- a/stack/src/arp.c +++ b/stack/src/protocol-arp.c @@ -9,7 +9,7 @@ #include <mr_rtdev.h>
#include <sk_stack.h>
#include <sk_device.h>
-#include <rte_ip_frag.h>
+#include <rte_malloc.h>
int protocol_arp_init(struct mr_stack_instance * instance)
{
@@ -54,11 +54,10 @@ int protocol_arp_slave_dev_deinit(struct sk_dev_desc * dev) }
// ARP���Ĵ�����ں�����������̴�����
-int protocol_arp_entry(struct stack_dev_handle * dev_handle,
- struct rte_mbuf * in_pkt[], struct rte_mbuf * out_pkt[],
- unsigned int nr_in_pkt, unsigned int * nr_left_pkt)
+void protocol_serv_arp_entry(struct sk_dev_desc* dev_desc,
+ thread_id_t sid, struct rte_mbuf* mbufs_in[], int nr_mbufs_in)
{
- return 0;
+ return;
}
int protocol_arp_request_send(struct sk_dev_desc * dev, struct in_addr in_addr)
diff --git a/stack/src/protocol-icmp.c b/stack/src/protocol-icmp.c new file mode 100644 index 0000000..e1d80ef --- /dev/null +++ b/stack/src/protocol-icmp.c @@ -0,0 +1,9 @@ +
+#include <sk_device.h>
+#include <sk_stack.h>
+
+void protocol_serv_icmp_entry(struct sk_dev_desc* dev_desc, thread_id_t sid,
+ struct rte_mbuf* mbufs_in[], int nr_mbufs_in)
+{
+ return;
+}
\ No newline at end of file diff --git a/stack/src/protocol-tcp.c b/stack/src/protocol-tcp.c new file mode 100644 index 0000000..0af46d8 --- /dev/null +++ b/stack/src/protocol-tcp.c @@ -0,0 +1,8 @@ +#include <mr_common.h>
+#include <sk_protocol_tcp.h>
+
+void protocol_serv_tcp_entry(struct sk_dev_desc* dev_desc,
+ thread_id_t sid, struct rte_mbuf* mbufs_in[], int nr_mbufs_in)
+{
+ return;
+}
diff --git a/stack/src/protocol-udp.c b/stack/src/protocol-udp.c new file mode 100644 index 0000000..adf2c12 --- /dev/null +++ b/stack/src/protocol-udp.c @@ -0,0 +1,9 @@ +
+#include <sk_device.h>
+#include <sk_stack.h>
+
+void protocol_serv_udp_entry(struct sk_dev_desc* dev_desc,
+ thread_id_t sid, struct rte_mbuf* mbufs_in[], int nr_mbufs_in)
+{
+ return;
+}
\ No newline at end of file diff --git a/stack/src/rxtx.c b/stack/src/rxtx.c index 6f3d376..92fed52 100644 --- a/stack/src/rxtx.c +++ b/stack/src/rxtx.c @@ -1,4 +1,4 @@ -/* \brief ��Э��ջԭʼ���Ĵ�������
+/* \brief ��Э��ջ���Ĵ�������
*
* ģ�鴦������������Э��ջ�����ݱ��ĺ����������������ݱ���
*
@@ -6,3 +6,83 @@ * \date 2016-10-21
*/
+#include <assert.h>
+#include <sk_device.h>
+#include <sk_stack.h>
+#include <sk_protocol_udp.h>
+#include <sk_protocol_arp.h>
+#include <sk_protocol_tcp.h>
+#include <sk_protocol_icmp.h>
+
+
+struct packet_holder
+{
+ struct rte_mbuf * packets[MR_BURST_MAX];
+ unsigned int nr_packets;
+};
+
+enum sk_packet_type
+{
+ __PACKET_TYPE_ARP = 0,
+ __PACKET_TYPE_ICMP = 1,
+ __PACKET_TYPE_TCP = 2,
+ __PACKET_TYPE_UDP = 3,
+ __PACKET_TYPE_FRAG = 4,
+ __PACKET_TYPE_ELSE = 5,
+ __PACKET_TYPE_MAX
+};
+
+static inline enum sk_packet_type __get_packet_type(struct rte_mbuf * mbuf)
+{
+ if (mbuf->packet_type & RTE_PTYPE_L2_ETHER_ARP) return __PACKET_TYPE_ARP;
+ if (mbuf->packet_type & RTE_PTYPE_L4_ICMP) return __PACKET_TYPE_ICMP;
+ if (mbuf->packet_type & RTE_PTYPE_L4_TCP) return __PACKET_TYPE_TCP;
+ if (mbuf->packet_type & RTE_PTYPE_L4_UDP) return __PACKET_TYPE_UDP;
+ if (mbuf->packet_type & RTE_PTYPE_L4_FRAG) return __PACKET_TYPE_FRAG;
+ return __PACKET_TYPE_ELSE;
+}
+
+int sk_serv_device_tx_bulk(struct sk_dev_desc * dev_desc, thread_id_t sid,
+ struct rte_mbuf * mbufs_out[], int nr_mbufs_max)
+{
+ return 0;
+}
+
+int sk_serv_device_rx_bulk(struct sk_dev_desc * dev_desc, thread_id_t sid,
+ struct rte_mbuf * mbufs_in[], struct rte_mbuf * mbufs_out[], int nr_mbufs_in, int * nr_mbufs_out)
+{
+ struct packet_holder packets[__PACKET_TYPE_MAX];
+ for (int i = 0; i < __PACKET_TYPE_MAX; i++) packets[i].nr_packets = 0;
+
+ // ���ķ��࣬���ݱ���Э���ǩ
+ for(int i = 0; i < nr_mbufs_in; i++)
+ {
+ enum sk_packet_type index = __get_packet_type(mbufs_in[i]);
+ packets[index].packets[packets[index].nr_packets++] = mbufs_in[i];
+ }
+
+ // ARP���Ĵ���
+ protocol_serv_arp_entry(dev_desc, sid, packets[__PACKET_TYPE_ARP].packets,
+ packets[__PACKET_TYPE_ARP].nr_packets);
+
+ // ICMP���Ĵ���
+ protocol_serv_icmp_entry(dev_desc, sid, packets[__PACKET_TYPE_ICMP].packets,
+ packets[__PACKET_TYPE_TCP].nr_packets);
+
+ // TCP���Ĵ���
+ protocol_serv_tcp_entry(dev_desc, sid, packets[__PACKET_TYPE_TCP].packets,
+ packets[__PACKET_TYPE_TCP].nr_packets);
+
+ // UDP���Ĵ���
+ protocol_serv_udp_entry(dev_desc, sid, packets[__PACKET_TYPE_UDP].packets,
+ packets[__PACKET_TYPE_UDP].nr_packets);
+
+ // �������ı��ģ����ظ��ϲ�
+ for(int i = 0; i < packets[__PACKET_TYPE_ELSE].nr_packets; i++)
+ {
+ mbufs_out[i] = packets[__PACKET_TYPE_ELSE].packets[i];
+ assert(i <= nr_mbufs_in);
+ }
+
+ return 0;
+}
\ No newline at end of file diff --git a/stack/src/udp.c b/stack/src/udp.c deleted file mode 100644 index e69de29..0000000 --- a/stack/src/udp.c +++ /dev/null |
