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 5C6739A8A for ; Sat, 18 Apr 2015 02:00:53 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 17 Apr 2015 17:00:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,597,1422950400"; d="scan'208";a="711168276" Received: from kmsmsx152.gar.corp.intel.com ([172.21.73.87]) by fmsmga002.fm.intel.com with ESMTP; 17 Apr 2015 17:00:51 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.110.15) by KMSMSX152.gar.corp.intel.com (172.21.73.87) with Microsoft SMTP Server (TLS) id 14.3.224.2; Sat, 18 Apr 2015 08:00:50 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.223]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.204]) with mapi id 14.03.0224.002; Sat, 18 Apr 2015 08:00:49 +0800 From: "Ouyang, Changchun" To: "Richardson, Bruce" , "dev@dpdk.org" , "Wiles, Keith" Thread-Topic: [dpdk-dev] [RFC PATCH 3/4] add support for a ring to be a pktdev Thread-Index: AQHQeSGbYla6O3KStEuUlK/KjehtyZ1R4sWA Date: Sat, 18 Apr 2015 00:00:49 +0000 Message-ID: References: <1428954274-26944-1-git-send-email-keith.wiles@intel.com> <1429283804-28087-1-git-send-email-bruce.richardson@intel.com> <1429283804-28087-4-git-send-email-bruce.richardson@intel.com> In-Reply-To: <1429283804-28087-4-git-send-email-bruce.richardson@intel.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [RFC PATCH 3/4] add support for a ring to be a pktdev 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: Sat, 18 Apr 2015 00:00:54 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Bruce Richardson > Sent: Friday, April 17, 2015 11:17 PM > To: dev@dpdk.org; Wiles, Keith > Subject: [dpdk-dev] [RFC PATCH 3/4] add support for a ring to be a pktdev >=20 > Add a new public API function, and two internal wrapper functions so we c= an > use ring as a pktdev. > --- > lib/librte_ring/rte_ring.c | 41 > +++++++++++++++++++++++++++++++++++++++++ > lib/librte_ring/rte_ring.h | 3 +++ > 2 files changed, 44 insertions(+) >=20 > diff --git a/lib/librte_ring/Makefile b/lib/librte_ring/Makefile index > 84ad3d3..bc5dd09 100644 > --- a/lib/librte_ring/Makefile > +++ b/lib/librte_ring/Makefile > @@ -47,6 +47,6 @@ SRCS-$(CONFIG_RTE_LIBRTE_RING) :=3D rte_ring.c > SYMLINK-$(CONFIG_RTE_LIBRTE_RING)-include :=3D rte_ring.h >=20 > # this lib needs eal and rte_malloc > -DEPDIRS-$(CONFIG_RTE_LIBRTE_RING) +=3D lib/librte_eal lib/librte_malloc > +DEPDIRS-$(CONFIG_RTE_LIBRTE_RING) +=3D lib/librte_eal lib/librte_malloc > +lib/librte_pktdev >=20 > include $(RTE_SDK)/mk/rte.lib.mk > diff --git a/lib/librte_ring/rte_ring.c b/lib/librte_ring/rte_ring.c inde= x > c9e59d4..424da20 100644 > --- a/lib/librte_ring/rte_ring.c > +++ b/lib/librte_ring/rte_ring.c > @@ -86,6 +86,7 @@ > #include > #include > #include > +#include >=20 > #include "rte_ring.h" >=20 > @@ -208,6 +208,47 @@ rte_ring_create(const char *name, unsigned count, > int socket_id, > return r; > } >=20 > +static uint16_t > +dev_rx(void *r, struct rte_mbuf **pkts, uint16_t max_pkts) { > + return rte_ring_dequeue_burst(r, (void *)pkts, max_pkts); } > + > +static uint16_t > +dev_tx(void *r, struct rte_mbuf **pkts, uint16_t max_pkts) { > + return rte_ring_enqueue_burst(r, (void *)pkts, max_pkts); } > + > +#define rte_ring_dev_data rte_pkt_dev_data > + > +struct rte_pkt_dev * > +rte_ring_get_dev(struct rte_ring *r) > +{ > + struct ring_as_pktdev { > + RTE_PKT_DEV_HDR(rte_ring_dev); > + struct rte_ring_dev_data dev_data; > + void *ring; > + } *p; > + if (r =3D=3D NULL || > + (p =3D rte_zmalloc(NULL, sizeof(*p), 0)) =3D=3D NULL) > + return NULL; > + > + p->ring =3D r; > + p->rx_pkt_burst =3D dev_rx; > + p->tx_pkt_burst =3D dev_tx; > + p->data =3D &p->dev_data; > + > + snprintf(p->dev_data.name, sizeof(p->dev_data.name), "%s", r- > >name); > + p->dev_data.nb_rx_queues =3D 1; > + p->dev_data.nb_tx_queues =3D 1; > + p->dev_data.rx_queues =3D &p->ring; > + p->dev_data.tx_queues =3D &p->ring; Why rx and tx doesn't need different ring here? > + > + return (void *)p; > +} > + > + > /* > * change the high water mark. If *count* is 0, water marking is > * disabled > diff --git a/lib/librte_ring/rte_ring.h b/lib/librte_ring/rte_ring.h inde= x > af68888..c2f28be 100644 > --- a/lib/librte_ring/rte_ring.h > +++ b/lib/librte_ring/rte_ring.h > @@ -301,6 +302,10 @@ int rte_ring_init(struct rte_ring *r, const char *na= me, > unsigned count, struct rte_ring *rte_ring_create(const char *name, > unsigned count, > int socket_id, unsigned flags); >=20 > +struct rte_pkt_dev; > + > +struct rte_pkt_dev *rte_ring_get_dev(struct rte_ring *r); > + > /** > * Change the high water mark. > * > -- > 2.1.0