From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id DC357CACC for ; Thu, 30 Apr 2015 14:05:38 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 30 Apr 2015 05:04:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,676,1422950400"; d="scan'208";a="687979121" Received: from unknown (HELO Sent) ([10.217.248.194]) by orsmga001.jf.intel.com with SMTP; 30 Apr 2015 05:04:55 -0700 Received: by Sent (sSMTP sendmail emulation); Thu, 30 Apr 2015 14:04:12 +0116 From: Michal Jastrzebski To: dev@dpdk.org Date: Thu, 30 Apr 2015 14:02:33 +0200 Message-Id: <1430395354-4160-3-git-send-email-michalx.k.jastrzebski@intel.com> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1430395354-4160-1-git-send-email-michalx.k.jastrzebski@intel.com> References: <1430395354-4160-1-git-send-email-michalx.k.jastrzebski@intel.com> Subject: [dpdk-dev] [PATCH v2 2/3] port: added ipv6 fragmentation port X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Apr 2015 12:05:39 -0000 From: Maciej Gajdzica Added new port type - IPv6 Fragmentation port Signed-off-by: Maciej Gajdzica --- 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