From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM04-BN3-obe.outbound.protection.outlook.com (mail-eopbgr680082.outbound.protection.outlook.com [40.107.68.82]) by dpdk.org (Postfix) with ESMTP id 6E9371BE5D for ; Fri, 6 Jul 2018 07:20:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=37p3+N9/O27+CBuXk/lqpgTvRRFZjhAMhJzRgk1p61k=; b=cqNMdE8ay7w/ss0laEgfYq0bmOl3tyQdsTIuGFhJM7tIzBS+lVRKQyJ3MSNxu6PQuSOC6kdYI+Bgmtb5aaSkNFaMEW3JpcArGpzBVrpgbXAYyGgGfNEfB9mKbj+LHKZtjRSFj6gYQn+Y7xXTG7jSbg1Itg1noNBTZJX6p2Kircg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin (50.233.148.155) by CO2PR07MB2519.namprd07.prod.outlook.com (2603:10b6:102:13::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.930.20; Fri, 6 Jul 2018 05:20:31 +0000 Date: Fri, 6 Jul 2018 10:50:23 +0530 From: Jerin Jacob To: Nikhil Rao Cc: dev@dpdk.org Message-ID: <20180706052021.GB6922@jerin> References: <1530168490-23223-1-git-send-email-nikhil.rao@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1530168490-23223-1-git-send-email-nikhil.rao@intel.com> User-Agent: Mutt/1.10.0 (2018-05-17) X-Originating-IP: [50.233.148.155] X-ClientProxiedBy: BYAPR04CA0005.namprd04.prod.outlook.com (2603:10b6:a03:40::18) To CO2PR07MB2519.namprd07.prod.outlook.com (2603:10b6:102:13::6) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 52987498-64c6-4be6-bbef-08d5e300327d X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600053)(711020)(2017052603328)(7153060)(7193020); SRVR:CO2PR07MB2519; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2519; 3:8NF86ReH/zTp14bNeC3r2H935EHAL0bBLzXn1ecjxp/mmWN/Mg/ZwogjHblgfJJAK8GY/hPRU4N/FsBss2Z0VgpA0oMaAvTWzifXtuPDkf4eC2+SLSDIlyS/JdIAlfx+SJp9K6dwCA6RApHItZQZ6fKtTLi2793URx1IrvI95QqcfxeUG3DcURPcYVSPih4nKAdifAy4sIWsjtIROHryC0aelapyavCCb9CBV4eVpsvnanNn37ohm0HWiBrJe+tW; 25:yVDpSIAurlBuzgAGX5V5szRYnkgdXMIyghLSeN2AETcOmqFr3J+etSzh58qdFjy0u438rTieD5KxXsggxC9buKlXOatMrsK1/iBip4JQ0BAT3X8lg1dtDt1gJCTqn+cRBbmI/l3Lpv4ig/6k+NLIEBOulIfUx8iYwoVJdLyoBhiEKNxuyYzJTiw6YF0jPmPIfZ7EwEY4XUzx8gs94689Tlt5Wdutbu29iCGtwnj40BthiTnimUKTIcB7INqdvREq7PJWxvWNI+PX9GwP/mSLUn35mnf1n4w/zJCGaJxehdi68MYc5BPiDfR6+fOgWMSBovOstdBujup69R/sjD0+ng==; 31:VViAG63o71jYem1N9AhpNkI/wGtDGNLIlPVeX23jbOe5w/UgRgNWn4eG0PYgN9bUq0Y8uvLjQOkq84iXsJLF9fSBtbaXPshCLgoWmjKvpzPeeKvfdI6pNJPtVXmwrAvIkvVWvxWZjXVJnR8XdXcwvepo9suetXYS9aOqie1F24EtYbYnmMKIgagLFTk/2igwSKF5oWd1YgnzrVkrdJeTYtn+UVAr/xtEtWR23PWkpX8= X-MS-TrafficTypeDiagnostic: CO2PR07MB2519: X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2519; 20:7pJJimCPjKaDSS3O+d46XNAWvr7FfH7kst13QfNADXJnzWpKEOMoJVvy21GPf6v2eh7VCKpHFws/Zs6m21fkyGoZ09E1adGSTyNB4uANSzZBOl2tpQrp86ss4rcandgLs06CCZ7ikhctqP7rwHO1T2WMaMFV0+EzCgn2RSUUpDZ+urYexJfs03rUq3DxYeNuRX2hRKT3YiACzFv6zP/F3GwmU/uMowdnGprPPPD0LIETMk34PHZqf1mHcerSqc/KZOmUmN1HOCNnVxHzE5Jz4Gkjsh/fFeH7G2iqB6uO3kinNye3IU3D563ooBTkzqhIgrqJqf9SJNzUyyPz3/eDKKRrdECRPH/3kLmLGq9OAXNg/GjKp9dfa9aesAvX3DAonG2ybTUomP4pwPbLOn6jX9jEd7r70i0m9ph1u0tAinP2qZSSVpo//FHrfX6eXSAl5bN+XgFM9hMUdEB/+cGwggfj1TVQRrA0Yw7fe9vowNNCRiMudQ0qOW048x4WnseEW/q+AubxEdQmuY1/hhuxxMb2vdEx2eQBFab/XmjuaCsz+/uExDUzsz1WdQryCQbzR/K9aODkzpIL0H8+loosHUUFM6nPOPZvMqRtCKeLfKU=; 4:g45U9cYUfifOy9H4xXTlhewejQeFcKQGNH3W/egQRYswbabHnZAOOdcz04+xBDF5YgYwt4d8Y/Yc2tCC7HsejM9Kix34fvlgcuzdtkxFOLzKZ6K/XKophZk6VLc59VBfUDOYqQz6eLvOFaf1NduuGbnKFzuEBFQB0Se7azM3eLC9cNFXx4KGmy95eDG1/REHBOF70ppEmNNML31gGyow3eONWeyM53GI1YZTTsxIlIlX5uIV285pudfHeq4CwDputAraO8pSfTl1cooEUYVQUkMtdeouvjwUlQrFG9E9teAJHH+dRYEqLQ3g1ugGSrfG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(3231254)(944501410)(52105095)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011)(7699016); SRVR:CO2PR07MB2519; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB2519; X-Forefront-PRVS: 0725D9E8D0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(346002)(376002)(366004)(39860400002)(136003)(396003)(13464003)(54534003)(189003)(199004)(76176011)(486006)(229853002)(52116002)(33896004)(58126008)(9686003)(16586007)(47776003)(66066001)(97736004)(11346002)(446003)(316002)(55016002)(16526019)(42882007)(386003)(14444005)(44832011)(186003)(956004)(476003)(6496006)(26005)(68736007)(72206003)(6246003)(305945005)(3846002)(23726003)(8676002)(50466002)(6916009)(33656002)(6666003)(33716001)(5660300001)(53936002)(25786009)(478600001)(7736002)(4326008)(105586002)(106356001)(2906002)(6116002)(1076002)(81156014)(81166006)(8936002)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB2519; H:jerin; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB2519; 23:neu3jnQDMS1jW8Msv32PxBczyINi/dE0Ne4suLMFv?= =?us-ascii?Q?LiDL+3d3U0msNA5vOwsc9uo81OJ/qkgKqxPei6ggiLD25eueRUO9h6nWGPmd?= =?us-ascii?Q?xS/pMa/SyBqMwWUm6DzWYzvV+bS7hqhP2tPXKQDgWMDJzrJKXUf+g4tzE/iA?= =?us-ascii?Q?yP1Kub145W/mKCB3idWyVsbZpXNHsudyOUggWvzmiOEfgUjdOjkUvWPx6rsZ?= =?us-ascii?Q?gy3sS60b0yIGVZAuR4mL4At8DW+KmJdhOqGDFCGpPTpmm58ANe3sLUtUscC8?= =?us-ascii?Q?ygefdXCJvzaz2uinxUX68qUdcqEO2hSZHa8xd6IVuRPThmDGClmZmXAQPlvK?= =?us-ascii?Q?dVL9uA0HuWjEnrQVTGGX65HIjUuqEbHNxo6R4C0410FXHCWjg8ui7xF0Vis5?= =?us-ascii?Q?GYkrsmgmpFRjpA7XSADXcWun0jb9pVoz5f+X6O41obuIbPQisbmmy463UkuI?= =?us-ascii?Q?ERfQTL5vr+q+axfdD2z9QubvBXf6wnRF7WNoFQmm5FKGH7mQOv173ZZFl21Z?= =?us-ascii?Q?SmZzimf7EPxwoYzcZKsXfuqPID0VHmr2CTT9FBcYzZI4yHWlhvOl0203hZQA?= =?us-ascii?Q?IOyf0/pPEauawAEmaqA4esLHoMlmsQXe/YL+Zq0on6Tt1jTLpYtyS8Oaiq2k?= =?us-ascii?Q?7TUlGksc/f0uJab7xC2iKF9NpL6VWiLOXmnAHuC+FNSJZe1KwaIMfnDN3TeJ?= =?us-ascii?Q?DhuXYihhfOTzq5x07kj41rNAC1JCI8N/PjeGWHeYXY4eDRy1rXLd85FXvihx?= =?us-ascii?Q?9JDmOpfVGLAFT3IP2u8sbn+r8iCvOOtn9J3waXio3R7nXCtMBg7KfbFePAfo?= =?us-ascii?Q?gO+Ds/39j5kG3A7JTZMgdesUei2suklEq04Y0lqr5CNRiuc0FbRHK5CQ2XD8?= =?us-ascii?Q?KRo4+k9S0gK5ZVavaarBslQJvc4lAyVBCvSuYVKy3vR2oVYnOTm7fpHAXoGM?= =?us-ascii?Q?H5bMgl/VBcr5KhracKj5mYA9xH9A6V6eaTJdYRp5qrgOWvLMcbBdY7g7Y4/S?= =?us-ascii?Q?jXBw26GVfYJ6HujgQ3a4WoNwRQ/+BDd/Nj7TUoLFXWOsGnUkO1ABoO3XlhRT?= =?us-ascii?Q?5dgEzzT82QrHmV6apvmofTXzhDTr2vuf0bjLoZXR7uQ46tDHw5gbU0qjhBc8?= =?us-ascii?Q?vBgC0UHSJeHC7esGCI7ec/wKLps98vFBCAe071ieLXfn9N5L6T7j+fCeuG56?= =?us-ascii?Q?+EBYW4FecTcOl+RJ8YdbFt7+OiLkuc3m2diPzca1onmxwj9AVFibuWqKRdCA?= =?us-ascii?Q?bM0+fnILKfCS2yGIjGeJeKis1c2ewNtJfxi735c7hZQcIDhjKP/qjZiZGUd7?= =?us-ascii?Q?Kl11WOFJUtChh+6rkqYz3gRU3xEfjQfAA06qi3X4VlAab9ATqJtqPK9c8M0F?= =?us-ascii?Q?0n4Kg=3D=3D?= X-Microsoft-Antispam-Message-Info: QmGydbkCerFCHfILj2m8zRh/t/WAZdNPqtELuqBxKGZo4joliJ9ViL6rlFzPzDmeaD5KZDLuGq48TabLgo/oDa5qzWh4+e1N3caavWII7Har/FhJSQw+FQBdvimHtqXjL1JJg4XwWxy4Do94zP5gwN5mX4ECNPf+Jb2mCnN3gJshKUI9kzucpCk9ao1yL6D9Q95LmQq5D6idxHem8hTI0Q4kpaKxjYI/0TnzR/y7yoIDOYMv+syxTIl9xNNQxKQlxTaWPr9E13X/ASJKjxVKL6TFDiGBT0WWM1e4rTxxHI4dehqhXM7EfortLdnn5wHzOMIpcGU20FRnq2BOKMz/AnumFsymvXJJmqbKFU5U6cw= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2519; 6:Zs75JCsFXyjgBVHsBPPwj0G5bdku7+rDDcnYle6B/K2zmwEG2tmECSalu2uH5QGiSvFzWkR3sDSv1lrxHGMpaLAAqMFWbkcTruOQVPJQqEkMa/fERlo+9k9fX3iER4v9TVDI0X4shBdace70A1pUD98/HrHe3kaiS6lPnfwQ65ZthRqDnMGbRggIDslobvDkjBKe26saCKLPQSvfANvc89e6hK9iOtTAPOyFJ7q1IIgrN9vj5zb5x1u15DdXLp5r9g1x1Sdh/RyZm2ep2ba1L11o4KFb5t/FxLNPzVj1g0qcxVWDSd7nudpkE70H1Shu9NLHvyq/2fEc1U0DtkxNRjjldLoV5a1ezwgZIMYD/LGbTMqZ6skx0EBMzdQqo2GnP8DzOhYZAcrEVJ6ieMwQhOPwl4xN+8QlS8E1Mnw02kHuCrz7etKZ6WGW909zFuKdC7FQBOXeu0tXGY4tU2HNLA==; 5:anMKxcVRrNO3iKlpoGEblBJ+G2DcouGu2Xua5WKmAax4sLbSmuet3mX5VdkfkYx9F4I+md3uLcqL+MbJjgzkPhEmJbXTNa4i16bDUUKGIgr8UUXJxZI8TQ+QmsBTN56bbl8fkEw+M/hnbdwRF9XFwFPF2A0QdxsakS0+TuX7VRc=; 24:SRAIIJbcOl5BHRFUS5WCLoFAhkwHku7Xkf1nQL4kbqdKCBjrT5w5yhyvtZKMv8EspfwnMfimcN70iU2CezXmVMbj5xXPUx/kUmeiCenNW4o= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB2519; 7:YXk3wIiMbu/jge39bytplaf672clOImDBGj4F78Ql41Ffzm79bGbydlNwswnv3v7cwUPtYddnHP0XeJZ3f7MJ/yQibxAi81QZqRdX/QX0R11aLIbO5SJhjkHMP/kRBmSTJedtyWKs9KOccyFmwB30AnU5hKmq9CH3SFOJQnJmU8jdChv2OC1xo5vUygnsegAE9V0aGhQKxkoF7yUQidaUxGFn/oVURcqHAbKY12qZPxKlUWi5rgwcipmh8pLzZOM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2018 05:20:31.3774 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 52987498-64c6-4be6-bbef-08d5e300327d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB2519 Subject: Re: [dpdk-dev] [PATCH v2] eventdev: add callback for Rx adapter SW transfers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 06 Jul 2018 05:20:36 -0000 -----Original Message----- > Date: Thu, 28 Jun 2018 12:18:10 +0530 > From: Nikhil Rao > To: jerin.jacob@caviumnetworks.com > CC: nikhil.rao@intel.com, dev@dpdk.org > Subject: [PATCH v2] eventdev: add callback for Rx adapter SW transfers > X-Mailer: git-send-email 1.8.3.1 > > External Email > > Add ability for application to register a callback function > for SW transfers, the callback can decide which packets can > be enqueued to the event device. > > Signed-off-by: Nikhil Rao > Acked-by: Jerin Jacob > --- Applied to dpdk-next-eventdev/master. Thanks. > > Changelog > ========= > > v1->v2: > * Change function names to rte_event_eth_rx_adapter_ namespace. (Jerin Jacob) > * Sort function names in map file alphabetically. (Jerin Jacob) > * Doc updated to mention RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT. (Jerin Jacob) > * Fix logic that handles callback return value. > > lib/librte_eventdev/rte_event_eth_rx_adapter.h | 81 ++++++++++++++++++++++ > lib/librte_eventdev/rte_event_eth_rx_adapter.c | 70 ++++++++++++++++++- > .../prog_guide/event_ethernet_rx_adapter.rst | 17 +++++ > lib/librte_eventdev/rte_eventdev_version.map | 25 +++---- > 4 files changed, 178 insertions(+), 15 deletions(-) > > diff --git a/lib/librte_eventdev/rte_event_eth_rx_adapter.h b/lib/librte_eventdev/rte_event_eth_rx_adapter.h > index 97f25e9..332ee21 100644 > --- a/lib/librte_eventdev/rte_event_eth_rx_adapter.h > +++ b/lib/librte_eventdev/rte_event_eth_rx_adapter.h > @@ -63,6 +63,20 @@ > * rte_event_eth_rx_adapter_service_id_get() function can be used to retrieve > * the service function ID of the adapter in this case. > * > + * For SW based packet transfers, i.e., when the > + * RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT is not set in the adapter's > + * capabilities flags for a particular ethernet device, the service function > + * temporarily enqueues mbufs to an event buffer before batch enqueueing these > + * to the event device. If the buffer fills up, the service function stops > + * dequeueing packets from the ethernet device. The application may want to > + * monitor the buffer fill level and instruct the service function to > + * selectively buffer packets. The application may also use some other > + * criteria to decide which packets should enter the event device even when > + * the event buffer fill level is low. The > + * rte_event_eth_rx_adapter_cb_register() function allows the > + * application to register a callback that selects which packets to enqueue > + * to the event device. > + * > * Note: > * 1) Devices created after an instance of rte_event_eth_rx_adapter_create > * should be added to a new instance of the rx adapter. > @@ -206,6 +220,47 @@ struct rte_event_eth_rx_adapter_stats { > * @warning > * @b EXPERIMENTAL: this API may change without prior notice > * > + * Callback function invoked by the SW adapter before it continues > + * to process packets. The callback is passed the size of the enqueue > + * buffer in the SW adapter and the occupancy of the buffer. The > + * callback can use these values to decide which mbufs should be > + * enqueued to the event device. If the return value of the callback > + * is less than nb_mbuf then the SW adapter uses the return value to > + * enqueue enq_mbuf[] to the event device. > + * > + * @param eth_dev_id > + * Port identifier of the Ethernet device. > + * @param queue_id > + * Receive queue index. > + * @param enqueue_buf_size > + * Total enqueue buffer size. > + * @param enqueue_buf_count > + * mbuf count in enqueue buffer. > + * @param mbuf > + * mbuf array. > + * @param nb_mbuf > + * mbuf count. > + * @param cb_arg > + * Callback argument. > + * @param[out] enq_mbuf > + * The adapter enqueues enq_mbuf[] if the return value of the > + * callback is less than nb_mbuf > + * @return > + * Returns the number of mbufs should be enqueued to eventdev > + */ > +typedef uint16_t (*rte_event_eth_rx_adapter_cb_fn)(uint16_t eth_dev_id, > + uint16_t queue_id, > + uint32_t enqueue_buf_size, > + uint32_t enqueue_buf_count, > + struct rte_mbuf **mbuf, > + uint16_t nb_mbuf, > + void *cb_arg, > + struct rte_mbuf **enq_buf); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > * Create a new ethernet Rx event adapter with the specified identifier. > * > * @param id > @@ -426,6 +481,32 @@ int rte_event_eth_rx_adapter_stats_get(uint8_t id, > */ > int rte_event_eth_rx_adapter_service_id_get(uint8_t id, uint32_t *service_id); > > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change without prior notice > + * > + * Register callback to process Rx packets, this is supported for > + * SW based packet transfers. > + * @see rte_event_eth_rx_cb_fn > + * > + * @param id > + * Adapter identifier. > + * @param eth_dev_id > + * Port identifier of Ethernet device. > + * @param cb_fn > + * Callback function. > + * @param cb_arg > + * Callback arg. > + * @return > + * - 0: Success > + * - <0: Error code on failure. > + */ > +int __rte_experimental > +rte_event_eth_rx_adapter_cb_register(uint8_t id, > + uint16_t eth_dev_id, > + rte_event_eth_rx_adapter_cb_fn cb_fn, > + void *cb_arg); > + > #ifdef __cplusplus > } > #endif > diff --git a/lib/librte_eventdev/rte_event_eth_rx_adapter.c b/lib/librte_eventdev/rte_event_eth_rx_adapter.c > index 8b86b18..8821e33 100644 > --- a/lib/librte_eventdev/rte_event_eth_rx_adapter.c > +++ b/lib/librte_eventdev/rte_event_eth_rx_adapter.c > @@ -147,6 +147,10 @@ struct rte_event_eth_rx_adapter { > struct eth_device_info { > struct rte_eth_dev *dev; > struct eth_rx_queue_info *rx_queue; > + /* Rx callback */ > + rte_event_eth_rx_adapter_cb_fn cb_fn; > + /* Rx callback argument */ > + void *cb_arg; > /* Set if ethdev->eventdev packet transfer uses a > * hardware mechanism > */ > @@ -759,11 +763,12 @@ static uint16_t rxa_gcd_u16(uint16_t a, uint16_t b) > uint16_t num) > { > uint32_t i; > - struct eth_device_info *eth_device_info = > + struct eth_device_info *dev_info = > &rx_adapter->eth_devices[eth_dev_id]; > struct eth_rx_queue_info *eth_rx_queue_info = > - ð_device_info->rx_queue[rx_queue_id]; > - > + &dev_info->rx_queue[rx_queue_id]; > + struct rte_eth_event_enqueue_buffer *buf = > + &rx_adapter->event_enqueue_buffer; > int32_t qid = eth_rx_queue_info->event_queue_id; > uint8_t sched_type = eth_rx_queue_info->sched_type; > uint8_t priority = eth_rx_queue_info->priority; > @@ -774,6 +779,8 @@ static uint16_t rxa_gcd_u16(uint16_t a, uint16_t b) > uint32_t rss; > int do_rss; > uint64_t ts; > + struct rte_mbuf *cb_mbufs[BATCH_SIZE]; > + uint16_t nb_cb; > > /* 0xffff ffff if PKT_RX_RSS_HASH is set, otherwise 0 */ > rss_mask = ~(((m->ol_flags & PKT_RX_RSS_HASH) != 0) - 1); > @@ -789,6 +796,19 @@ static uint16_t rxa_gcd_u16(uint16_t a, uint16_t b) > } > } > > + > + nb_cb = dev_info->cb_fn ? dev_info->cb_fn(eth_dev_id, rx_queue_id, > + ETH_EVENT_BUFFER_SIZE, > + buf->count, mbufs, > + num, > + dev_info->cb_arg, > + cb_mbufs) : > + num; > + if (nb_cb < num) { > + mbufs = cb_mbufs; > + num = nb_cb; > + } > + > for (i = 0; i < num; i++) { > m = mbufs[i]; > struct rte_event *ev = &events[i]; > @@ -2365,3 +2385,47 @@ static int rxa_sw_add(struct rte_event_eth_rx_adapter *rx_adapter, > > return rx_adapter->service_inited ? 0 : -ESRCH; > } > + > +int rte_event_eth_rx_adapter_cb_register(uint8_t id, > + uint16_t eth_dev_id, > + rte_event_eth_rx_adapter_cb_fn cb_fn, > + void *cb_arg) > +{ > + struct rte_event_eth_rx_adapter *rx_adapter; > + struct eth_device_info *dev_info; > + uint32_t cap; > + int ret; > + > + RTE_EVENT_ETH_RX_ADAPTER_ID_VALID_OR_ERR_RET(id, -EINVAL); > + RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_dev_id, -EINVAL); > + > + rx_adapter = rxa_id_to_adapter(id); > + if (rx_adapter == NULL) > + return -EINVAL; > + > + dev_info = &rx_adapter->eth_devices[eth_dev_id]; > + if (dev_info->rx_queue == NULL) > + return -EINVAL; > + > + ret = rte_event_eth_rx_adapter_caps_get(rx_adapter->eventdev_id, > + eth_dev_id, > + &cap); > + if (ret) { > + RTE_EDEV_LOG_ERR("Failed to get adapter caps edev %" PRIu8 > + "eth port %" PRIu16, id, eth_dev_id); > + return ret; > + } > + > + if (cap & RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT) { > + RTE_EDEV_LOG_ERR("Rx callback not supported for eth port %" > + PRIu16, eth_dev_id); > + return -EINVAL; > + } > + > + rte_spinlock_lock(&rx_adapter->rx_lock); > + dev_info->cb_fn = cb_fn; > + dev_info->cb_arg = cb_arg; > + rte_spinlock_unlock(&rx_adapter->rx_lock); > + > + return 0; > +} > diff --git a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst > index 2f055ec..91ecc1b 100644 > --- a/doc/guides/prog_guide/event_ethernet_rx_adapter.rst > +++ b/doc/guides/prog_guide/event_ethernet_rx_adapter.rst > @@ -168,3 +168,20 @@ received on a polled Rx queue. The interrupt thread is affinitized to the same > CPUs as the lcores of the Rx adapter service function, if the Rx adapter > service function has not been mapped to any lcores, the interrupt thread > is mapped to the master lcore. > + > +Rx Callback for SW Rx Adapter > +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > + > +For SW based packet transfers, i.e., when the > +``RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT`` is not set in the adapter's > +capabilities flags for a particular ethernet device, the service function > +temporarily enqueues mbufs to an event buffer before batch enqueueing these > +to the event device. If the buffer fills up, the service function stops > +dequeueing packets from the ethernet device. The application may want to > +monitor the buffer fill level and instruct the service function to selectively > +enqueue packets to the event device. The application may also use some other > +criteria to decide which packets should enter the event device even when > +the event buffer fill level is low. The > +``rte_event_eth_rx_adapter_cb_register()`` function allow the application > +to register a callback that selects which packets to enqueue to the event > +device. > diff --git a/lib/librte_eventdev/rte_eventdev_version.map b/lib/librte_eventdev/rte_eventdev_version.map > index c3f18d6..12835e9 100644 > --- a/lib/librte_eventdev/rte_eventdev_version.map > +++ b/lib/librte_eventdev/rte_eventdev_version.map > @@ -83,6 +83,19 @@ DPDK_18.05 { > EXPERIMENTAL { > global: > > + rte_event_crypto_adapter_caps_get; > + rte_event_crypto_adapter_create; > + rte_event_crypto_adapter_create_ext; > + rte_event_crypto_adapter_event_port_get; > + rte_event_crypto_adapter_free; > + rte_event_crypto_adapter_queue_pair_add; > + rte_event_crypto_adapter_queue_pair_del; > + rte_event_crypto_adapter_service_id_get; > + rte_event_crypto_adapter_start; > + rte_event_crypto_adapter_stats_get; > + rte_event_crypto_adapter_stats_reset; > + rte_event_crypto_adapter_stop; > + rte_event_eth_rx_adapter_cb_register; > rte_event_timer_adapter_caps_get; > rte_event_timer_adapter_create; > rte_event_timer_adapter_create_ext; > @@ -97,16 +110,4 @@ EXPERIMENTAL { > rte_event_timer_arm_burst; > rte_event_timer_arm_tmo_tick_burst; > rte_event_timer_cancel_burst; > - rte_event_crypto_adapter_caps_get; > - rte_event_crypto_adapter_create; > - rte_event_crypto_adapter_create_ext; > - rte_event_crypto_adapter_event_port_get; > - rte_event_crypto_adapter_free; > - rte_event_crypto_adapter_queue_pair_add; > - rte_event_crypto_adapter_queue_pair_del; > - rte_event_crypto_adapter_service_id_get; > - rte_event_crypto_adapter_start; > - rte_event_crypto_adapter_stats_get; > - rte_event_crypto_adapter_stats_reset; > - rte_event_crypto_adapter_stop; > }; > -- > 1.8.3.1 >