From: Maciej Gajdzica <maciejx.t.gajdzica@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 2/3] port: added ipv6 fragmentation port
Date: Mon, 30 Mar 2015 12:15:16 +0200 [thread overview]
Message-ID: <1427710517-29001-3-git-send-email-maciejx.t.gajdzica@intel.com> (raw)
In-Reply-To: <1427710517-29001-1-git-send-email-maciejx.t.gajdzica@intel.com>
---
lib/librte_port/rte_port_frag.c | 61 +++++++++++++++++++++++++++++----------
lib/librte_port/rte_port_frag.h | 9 +++++-
2 files changed, 54 insertions(+), 16 deletions(-)
diff --git a/lib/librte_port/rte_port_frag.c b/lib/librte_port/rte_port_frag.c
index dce33d5..c4c05dc 100644
--- a/lib/librte_port/rte_port_frag.c
+++ b/lib/librte_port/rte_port_frag.c
@@ -39,9 +39,17 @@
#include "rte_port_frag.h"
/* Max number of fragments per packet allowed */
-#define IPV4_MAX_FRAGS_PER_PACKET 0x80
+#define RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET 0x80
-struct rte_port_ring_reader_ipv4_frag {
+typedef int32_t
+ (*frag_op)(struct rte_mbuf *pkt_in,
+ struct rte_mbuf **pkts_out,
+ uint16_t nb_pkts_out,
+ uint16_t mtu_size,
+ struct rte_mempool *pool_direct,
+ struct rte_mempool *pool_indirect);
+
+struct rte_port_ring_reader_frag {
/* Input parameters */
struct rte_ring *ring;
uint32_t mtu;
@@ -51,19 +59,21 @@ struct rte_port_ring_reader_ipv4_frag {
/* Internal buffers */
struct rte_mbuf *pkts[RTE_PORT_IN_BURST_SIZE_MAX];
- struct rte_mbuf *frags[IPV4_MAX_FRAGS_PER_PACKET];
+ struct rte_mbuf *frags[RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET];
uint32_t n_pkts;
uint32_t pos_pkts;
uint32_t n_frags;
uint32_t pos_frags;
+
+ frag_op f_frag;
} __rte_cache_aligned;
static void *
-rte_port_ring_reader_ipv4_frag_create(void *params, int socket_id)
+rte_port_ring_reader_frag_create(void *params, int socket_id, int is_ipv4)
{
- struct rte_port_ring_reader_ipv4_frag_params *conf =
- (struct rte_port_ring_reader_ipv4_frag_params *) params;
- struct rte_port_ring_reader_ipv4_frag *port;
+ struct rte_port_ring_reader_frag_params *conf =
+ (struct rte_port_ring_reader_frag_params *) params;
+ struct rte_port_ring_reader_frag *port;
/* Check input parameters */
if (conf == NULL) {
@@ -109,16 +119,31 @@ rte_port_ring_reader_ipv4_frag_create(void *params, int socket_id)
port->n_frags = 0;
port->pos_frags = 0;
+ port->f_frag = (is_ipv4) ?
+ rte_ipv4_fragment_packet : rte_ipv6_fragment_packet;
+
return port;
}
+static void *
+rte_port_ring_reader_ipv4_frag_create(void *params, int socket_id)
+{
+ return rte_port_ring_reader_frag_create(params, socket_id, 1);
+}
+
+static void *
+rte_port_ring_reader_ipv6_frag_create(void *params, int socket_id)
+{
+ return rte_port_ring_reader_frag_create(params, socket_id, 0);
+}
+
static int
-rte_port_ring_reader_ipv4_frag_rx(void *port,
+rte_port_ring_reader_frag_rx(void *port,
struct rte_mbuf **pkts,
uint32_t n_pkts)
{
- struct rte_port_ring_reader_ipv4_frag *p =
- (struct rte_port_ring_reader_ipv4_frag *) port;
+ struct rte_port_ring_reader_frag *p =
+ (struct rte_port_ring_reader_frag *) port;
uint32_t n_pkts_out;
n_pkts_out = 0;
@@ -167,10 +192,10 @@ rte_port_ring_reader_ipv4_frag_rx(void *port,
}
/* Fragment current packet into the "frags" buffer */
- status = rte_ipv4_fragment_packet(
+ status = p->f_frag(
pkt,
p->frags,
- IPV4_MAX_FRAGS_PER_PACKET,
+ RTE_PORT_FRAG_MAX_FRAGS_PER_PACKET,
p->mtu,
p->pool_direct,
p->pool_indirect
@@ -215,7 +240,7 @@ rte_port_ring_reader_ipv4_frag_rx(void *port,
}
static int
-rte_port_ring_reader_ipv4_frag_free(void *port)
+rte_port_ring_reader_frag_free(void *port)
{
if (port == NULL) {
RTE_LOG(ERR, PORT, "%s: Parameter port is NULL\n", __func__);
@@ -232,6 +257,12 @@ rte_port_ring_reader_ipv4_frag_free(void *port)
*/
struct rte_port_in_ops rte_port_ring_reader_ipv4_frag_ops = {
.f_create = rte_port_ring_reader_ipv4_frag_create,
- .f_free = rte_port_ring_reader_ipv4_frag_free,
- .f_rx = rte_port_ring_reader_ipv4_frag_rx,
+ .f_free = rte_port_ring_reader_frag_free,
+ .f_rx = rte_port_ring_reader_frag_rx,
+};
+
+struct rte_port_in_ops rte_port_ring_reader_ipv6_frag_ops = {
+ .f_create = rte_port_ring_reader_ipv6_frag_create,
+ .f_free = rte_port_ring_reader_frag_free,
+ .f_rx = rte_port_ring_reader_frag_rx,
};
diff --git a/lib/librte_port/rte_port_frag.h b/lib/librte_port/rte_port_frag.h
index dfd70c0..0085ff7 100644
--- a/lib/librte_port/rte_port_frag.h
+++ b/lib/librte_port/rte_port_frag.h
@@ -63,7 +63,7 @@ extern "C" {
#include "rte_port.h"
/** ring_reader_ipv4_frag port parameters */
-struct rte_port_ring_reader_ipv4_frag_params {
+struct rte_port_ring_reader_frag_params {
/** Underlying single consumer ring that has to be pre-initialized. */
struct rte_ring *ring;
@@ -84,9 +84,16 @@ struct rte_port_ring_reader_ipv4_frag_params {
struct rte_mempool *pool_indirect;
};
+#define rte_port_ring_reader_ipv4_frag_params rte_port_ring_reader_frag_params
+
+#define rte_port_ring_reader_ipv6_frag_params rte_port_ring_reader_frag_params
+
/** ring_reader_ipv4_frag port operations */
extern struct rte_port_in_ops rte_port_ring_reader_ipv4_frag_ops;
+/** ring_reader_ipv6_frag port operations */
+extern struct rte_port_in_ops rte_port_ring_reader_ipv6_frag_ops;
+
#ifdef __cplusplus
}
#endif
--
1.7.9.5
next prev parent reply other threads:[~2015-03-30 10:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-30 10:15 [dpdk-dev] [PATCH 0/3] port: added frag_ipv6 and ras_ipv6 ports Maciej Gajdzica
2015-03-30 10:15 ` [dpdk-dev] [PATCH 1/3] port: removed IPV4_MTU_DEFAULT define Maciej Gajdzica
2015-03-30 10:15 ` Maciej Gajdzica [this message]
2015-03-30 10:15 ` [dpdk-dev] [PATCH 3/3] port: added ipv6 reassembly port Maciej Gajdzica
2015-03-30 11:56 ` [dpdk-dev] [PATCH 0/3] port: added frag_ipv6 and ras_ipv6 ports Dumitrescu, Cristian
2015-04-28 15:43 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1427710517-29001-3-git-send-email-maciejx.t.gajdzica@intel.com \
--to=maciejx.t.gajdzica@intel.com \
--cc=dev@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).