diff --git a/sdk/include/packet.h b/sdk/include/packet.h index c9360df..7adfffd 100644 --- a/sdk/include/packet.h +++ b/sdk/include/packet.h @@ -3,5 +3,7 @@ #include "marsio.h" struct packet { + /* queue id which the packet belongs to */ + int qid; }; diff --git a/src/packet_io/marsio_mode/pio_marsio.cpp b/src/packet_io/marsio_mode/pio_marsio.cpp index 460bfe8..7227c40 100644 --- a/src/packet_io/marsio_mode/pio_marsio.cpp +++ b/src/packet_io/marsio_mode/pio_marsio.cpp @@ -322,6 +322,12 @@ int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struc return g_marsio_dll_func.marsio_send_burst(sendpath_handle, txq_id, (marsio_buff_t **)pkts, nr_pkts); } +void pio_marsio_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts) +{ + struct mr_instance *mr_inst = pdev->ppio_inst->entity.marsio_inst->mr_inst_handle; + g_marsio_dll_func.marsio_buff_free(mr_inst, (marsio_buff_t **)pkts, nr_pkts, MARSIO_SOCKET_ID_ANY, qid); +} + static int marsio_instance_init(struct packet_io_instance *pinst, int wrk_thread_num) { int ret = -1; diff --git a/src/packet_io/marsio_mode/pio_marsio.h b/src/packet_io/marsio_mode/pio_marsio.h index 4964d4c..0db08c2 100644 --- a/src/packet_io/marsio_mode/pio_marsio.h +++ b/src/packet_io/marsio_mode/pio_marsio.h @@ -116,6 +116,8 @@ int pio_marsio_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, st int pio_marsio_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts); +void pio_marsio_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts); + int pio_marsio_instance_create(struct packet_io_instance *pinst, int wrk_thread_num); void pio_marsio_instance_destroy(struct packet_io_instance *pinst); \ No newline at end of file diff --git a/src/packet_io/packet_io.cpp b/src/packet_io/packet_io.cpp index 24ec26e..87b3c5c 100644 --- a/src/packet_io/packet_io.cpp +++ b/src/packet_io/packet_io.cpp @@ -22,6 +22,7 @@ struct pio_device_operations pio_device_ops_array[PACKET_IO_RUN_MODE_MAX] = .close = pio_pcap_file_device_close, .recv = pio_pcap_file_device_receive, .send = pio_pcap_file_device_send, + .pkt_free = pio_pcap_file_device_pkt_free, }, { @@ -29,6 +30,7 @@ struct pio_device_operations pio_device_ops_array[PACKET_IO_RUN_MODE_MAX] = .close = pio_pcap_live_device_close, .recv = pio_pcap_live_device_receive, .send = pio_pcap_live_device_send, + .pkt_free = pio_pcap_live_device_pkt_free, }, { @@ -36,6 +38,7 @@ struct pio_device_operations pio_device_ops_array[PACKET_IO_RUN_MODE_MAX] = .close = pio_marsio_device_close, .recv = pio_marsio_device_receive, .send = pio_marsio_device_send, + .pkt_free = pio_marsio_device_pkt_free, } }; @@ -140,12 +143,17 @@ void packet_io_device_close(struct packet_io_device *pdev) FREE(pdev); } -int packet_io_device_rx(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p) +int packet_io_device_rx(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts) { - return pdev->dev_ops->recv(pdev, rxq_id, p, nr_p); + return pdev->dev_ops->recv(pdev, rxq_id, pkts, nr_pkts); } -int packet_io_device_tx(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p) +int packet_io_device_tx(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts) { - return pdev->dev_ops->send(pdev, txq_id, p, nr_p); + return pdev->dev_ops->send(pdev, txq_id, pkts, nr_pkts); +} + +void packet_io_pkts_free(struct packet_io_instance *pinst, uint32_t qid, struct packet **pkts, int nr_pkts) +{ + } \ No newline at end of file diff --git a/src/packet_io/packet_io.h b/src/packet_io/packet_io.h index 7ba5077..d220c5e 100644 --- a/src/packet_io/packet_io.h +++ b/src/packet_io/packet_io.h @@ -60,9 +60,11 @@ struct pio_device_operations { int (*close)(const struct packet_io_device *pdev); - int (*recv)(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int pkt_cnt); + int (*recv)(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts); - int (*send)(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int pkt_cnt); + int (*send)(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts); + + void (*pkt_free)(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts); }; struct packet_io_device { @@ -120,7 +122,7 @@ void packet_io_device_close(struct packet_io_device *dev); * @param p: received packet's pointer array * @param nr_p: number of received packets **/ -int packet_io_device_rx(struct packet_io_device *pdev, uint32_t rxq_id, struct packet *p[], int nr_p); +int packet_io_device_rx(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts); /* * @brief packet_io device send function @@ -130,4 +132,9 @@ int packet_io_device_rx(struct packet_io_device *pdev, uint32_t rxq_id, struct p * @param p: prepare to send packet's pointer array * @param nr_p: number of packets which prepare to send **/ -int packet_io_device_tx(struct packet_io_device *pdev, uint32_t txq_id, struct packet *p[], int nr_p); \ No newline at end of file +int packet_io_device_tx(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts); + +/* + * @brief packet_io free packet buff +**/ +void packet_io_pkts_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts); \ No newline at end of file diff --git a/src/packet_io/pcap_file_mode/pio_pcap_file.cpp b/src/packet_io/pcap_file_mode/pio_pcap_file.cpp index 9cc1f70..ac1bc5a 100644 --- a/src/packet_io/pcap_file_mode/pio_pcap_file.cpp +++ b/src/packet_io/pcap_file_mode/pio_pcap_file.cpp @@ -12,32 +12,42 @@ #include "pio_pcap_file.h" -int pio_pcap_file_device_open(struct packet_io_device *pdev, const char *path, uint32_t nr_rxq, uint32_t nr_txq) { +int pio_pcap_file_device_open(struct packet_io_device *pdev, const char *path, uint32_t nr_rxq, uint32_t nr_txq) +{ return 0; } -int pio_pcap_file_device_close(const struct packet_io_device *pdev) { +int pio_pcap_file_device_close(const struct packet_io_device *pdev) +{ return 0; } -int pio_pcap_file_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts) { +int pio_pcap_file_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, struct packet **pkts, int nr_pkts) +{ return 0; } -int pio_pcap_file_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts) { +int pio_pcap_file_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts) +{ return 0; } +void pio_pcap_file_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts) +{ -int pio_pcap_file_instance_create(struct packet_io_instance *pinst, int wrk_thread_num) { +} + +int pio_pcap_file_instance_create(struct packet_io_instance *pinst, int wrk_thread_num) +{ return 0; } -void pio_pcap_file_instance_destroy(struct packet_io_instance *pinst) { +void pio_pcap_file_instance_destroy(struct packet_io_instance *pinst) +{ } \ No newline at end of file diff --git a/src/packet_io/pcap_file_mode/pio_pcap_file.h b/src/packet_io/pcap_file_mode/pio_pcap_file.h index 686d1d2..cefb369 100644 --- a/src/packet_io/pcap_file_mode/pio_pcap_file.h +++ b/src/packet_io/pcap_file_mode/pio_pcap_file.h @@ -45,6 +45,8 @@ int pio_pcap_file_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, int pio_pcap_file_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts); +void pio_pcap_file_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts); + int pio_pcap_file_instance_create(struct packet_io_instance *pinst, int wrk_thread_num); void pio_pcap_file_instance_destroy(struct packet_io_instance *pinst); \ No newline at end of file diff --git a/src/packet_io/pcap_live_mode/pio_pcap_live.cpp b/src/packet_io/pcap_live_mode/pio_pcap_live.cpp index 11d1bbc..bc9ab14 100644 --- a/src/packet_io/pcap_live_mode/pio_pcap_live.cpp +++ b/src/packet_io/pcap_live_mode/pio_pcap_live.cpp @@ -30,6 +30,11 @@ int pio_pcap_live_device_send(struct packet_io_device *pdev, uint32_t txq_id, st return 0; } +void pio_pcap_live_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts) +{ + +} + int pio_pcap_live_instance_create(struct packet_io_instance *pinst, int wrk_thread_num) { return 0; diff --git a/src/packet_io/pcap_live_mode/pio_pcap_live.h b/src/packet_io/pcap_live_mode/pio_pcap_live.h index db16f94..93f41f1 100644 --- a/src/packet_io/pcap_live_mode/pio_pcap_live.h +++ b/src/packet_io/pcap_live_mode/pio_pcap_live.h @@ -43,6 +43,8 @@ int pio_pcap_live_device_receive(struct packet_io_device *pdev, uint32_t rxq_id, int pio_pcap_live_device_send(struct packet_io_device *pdev, uint32_t txq_id, struct packet **pkts, int nr_pkts); +void pio_pcap_live_device_pkt_free(struct packet_io_device *pdev, uint32_t qid, struct packet **pkts, int nr_pkts); + int pio_pcap_live_instance_create(struct packet_io_instance *pinst, int wrk_thread_num); void pio_pcap_live_instance_destroy(struct packet_io_instance *pinst); \ No newline at end of file