From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-BL2-obe.outbound.protection.outlook.com (mail-bl2nam02on0071.outbound.protection.outlook.com [104.47.38.71]) by dpdk.org (Postfix) with ESMTP id E65EA9256 for ; Thu, 8 Sep 2016 09:29:10 +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; bh=33VwVu23BpG/L3yLG1CDV3JvK2frtrWdnTEWwjhGcv8=; b=UIlHDqq/SOM9/RapLlzIEtqafK5vkZkd6SuP/b55Sb2YLVVUkANIRbDqvKo/d/t5orpLJmjNLM9l4GmacU/PY3auH+U6t8rvLeZ2ylTfmZZPrCdBTCLt22rw2fzw/RnH+UgsG6j9fErE3YcOWRJ8aITvDw9PjMCleQj4OnhEn8A= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.Jacob@cavium.com; Received: from localhost.localdomain (171.61.104.44) by CY1PR0701MB1728.namprd07.prod.outlook.com (10.163.21.142) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.609.9; Thu, 8 Sep 2016 07:29:07 +0000 Date: Thu, 8 Sep 2016 12:58:47 +0530 From: Jerin Jacob To: Tomasz Kulasek CC: Message-ID: <20160908072845.GA7333@localhost.localdomain> References: <1472228578-6980-1-git-send-email-tomaszx.kulasek@intel.com> <1472228578-6980-2-git-send-email-tomaszx.kulasek@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <1472228578-6980-2-git-send-email-tomaszx.kulasek@intel.com> User-Agent: Mutt/1.6.2 (2016-07-01) X-Originating-IP: [171.61.104.44] X-ClientProxiedBy: BM1PR01CA0050.INDPRD01.PROD.OUTLOOK.COM (10.163.199.22) To CY1PR0701MB1728.namprd07.prod.outlook.com (10.163.21.142) X-MS-Office365-Filtering-Correlation-Id: 569bc918-4361-49b9-2baa-08d3d7b9d2a9 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1728; 2:7DwDQOFgDg1OhUc9EKSg0EIqbLwOE8Zl9LtUp0P58GruEnuQf6dlprqeKGa5wJlOsW4ZyTG7jHHQ8q9gq23O8PfWAfFa0mGzdqpxyMl3Eod39YlEL5cua6Qv+k0ZKkry83N4VC4/963EJmbSJJXGFz4WdYpAwJER9JBk2qWhEt7ty+i9c5ywFYdT91mkpMF4; 3:aJicWzfbUghrQGa4VYbhjjj3n9PWXz5fFQr4MvqCSiwzHSWt259VGNGJKpKlnIuprWimtqqG8LzH89M0CAgPooDaGEIflWIEMRZc23nrnqM7QlmccUxeN5+kY9Bc/Fcx X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0701MB1728; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1728; 25:Wv+DayqH3lpjfrL1M5lbN1Pi8AQIjM1xpRODvc1V+hwJrgrBNC8xncmomR2UHDN9yq4WLHGEYVxf6F1TZotIYqnekyBI3AKX+R/gaqNBNbBvTYj9ZFTktxCODZTH0EhzLY6QDUE4TQfxQ2p5GzK73P64opIELx8c8LP7ESfirQSSTfYJjXLbu/xsNBtQ+IAsK4jKK+0rCqYkLKNOGgu3CpX1QxK5tW6EiXjRA7KH10sLlJx5nS1nV+a9NXsfV+Hvyc0WxOH++831ckmAGUaCM7XEzSpriYfJxI1ibdS2erVu/uCiK5wrGzzUXFwPusWa30UxZDNTKIoBqzCSKJfZRxorKXOdAWMcdMX0A6qceYsivtAFTYU7wxVOxvvM3z8TGsLLADszDG6byNapWfCbXnwYf8COA8rDmNuZFf0rrTz+maeFrHFK8ls3gDLLpck9cQXKNEDcZRHpayeUAv0F4dVx/c0CwKezXKw4wPlvJcqMHlhCAJUm0A5Fl4iuDpb6gsASUpbyx3RfoWYa26wEIvjNj79MxefVlws0t3ZNUgdg3nOcD7dw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EGROP4q8pjUk9Jy27jONXS0SJZYU+PkWLco= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(228905959029699); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:CY1PR0701MB1728; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0701MB1728; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0701MB1728; 4:HfX6Jn78Z2R60ZWDddgSIR3aECDLRWKBQ/omIc461Sow1nxB+A+qE+GSXKkQ21HaEcSEQHG2zuvD9w42UiVCM9mg5e8M4wKjBL2gch8JomRf8hArUrpe8OJs0uquik49n8qtdTeZjO0b5DU6I6OwOZx1nwLKL9LF7N8Be5L3fI+SJjolMGapzmR1PMCjPWyL+4sRnqGRymALlJG8U3qhIG5TZ9+iGHACoiHNaHl0ELmKEbXm8qO0mDAxRuU8PS2a6ZXqL2ViLIPk7NMJcvgcddVTc12aHbW79lS2GtaM2bdQmcV46rhO5wjxgDC2XWSqX8ffviCXiUtF9v7QTLDJXLx1FfFdAQf4UszeLRCPCUGu4IKSqFup99SRGysLxTjEkbG62LjvAb9rP1j+i7c8e6J8L9/oI74ug0hffdG0WRUfGbL3LKX9PSWGNWmA0ThV X-Forefront-PRVS: 00594E8DBA X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(24454002)(6116002)(92566002)(586003)(189998001)(1076002)(3846002)(5660300001)(101416001)(46406003)(42186005)(47776003)(19580405001)(7846002)(19580395003)(4001350100001)(81156014)(7736002)(77096005)(8676002)(68736007)(23726003)(4326007)(81166006)(9686002)(2906002)(305945005)(97736004)(50466002)(97756001)(50986999)(61506002)(54356999)(83506001)(106356001)(110136002)(575784001)(66066001)(33656002)(105586002)(76176999)(2950100001)(18370500001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0701MB1728; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0701MB1728; 23:I45h6Dk+K9bRSfgq/Az0/M4u06Pa5KgcE35FIvE?= =?us-ascii?Q?BgvYPcubl/q3n7edpjiJrsqyjDgoLDeLfldloCtCUa5pI6iaeR0AtotT4RQW?= =?us-ascii?Q?2V2KyrDMEwQ0lWUoHRuWCokYuexzto9/NDai303GGWu4pmHrgCk7OD699hwA?= =?us-ascii?Q?C94Ewyq2AlLRQLpJOLo8NZSN0LzAo3IH0yE5AQAqD7TfX62MRF15LaR8dOeb?= =?us-ascii?Q?3E6kO3lc3TLYz4SNaEOwkdXkFIbTqUlcalUT7EBkcQPDSXhGRQGy2+ceSXOb?= =?us-ascii?Q?HyE9Hzqi6zQIsQq9qdsgfYK0lh789fTWq3wDZcaAPaI0PRsSOvWf1h3GnDsh?= =?us-ascii?Q?2GKrak98bHfj5LaiDPRQ18oBtZXh9oOP6iFwyCAA3f/Gy3gcaC5HOiHUqSDN?= =?us-ascii?Q?L48RTLsZ1dfaefVMtHcmuqDsdGmdFDnVC6nUa/llwaQVhGA1kuin4QR4fQu+?= =?us-ascii?Q?BxeK1VmELdeXdV4BLTVbkV80uQDn7JcEdNQwikmUpAYIiXeo4IuCQDZaLXvS?= =?us-ascii?Q?lcWwJCu3YRKnnBCp7E2dDx1HGhj6GrEPw3Qwss1FUEg1RTmFio36wW7EK7bi?= =?us-ascii?Q?KeID8b20Kw2cDuLIi9+DPt1KgbH2GscELYifTTlEA08HR2I8N2aS9W7jmjZe?= =?us-ascii?Q?crB3ubCWz+BAEdTpcigkq06BpoAMuVKiPhxsyw7JLRhllzje6t/7trBG0Ods?= =?us-ascii?Q?dKHwnpMMt03u3OvqRai70XKVUUAMG9A2NQg6joEpg0fFcdesuPuKGRrbbYDk?= =?us-ascii?Q?lerqkoFXmtDMhYdSjza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vz3ZRoAeM2Lp5/8JmDUtm0lHImwVeGiwZPCzEtWUzlFX3NEB1UvsxACxy95Dgt75slcVhUBYLapy/YAuXwIfeL7KAuavuMtVY=; 7:owgMskQ606GLHmicHJB8VsyMolmB4PVfi2QB23YvkaGcuROUyq1vcXN4qdzxQ4ZvuPnaDyMrUzNASFTGOlmZJVgqXZYCDM7MgK7o5x8RkHZYENxnio9lpzuUKbGca4qYrE0lAtZcOZajuEYCAOV5nyLLRAMRc1q3e90U7rELjnp8qLc0i8U2JO27PU5s0hfdT2t+TRxDw/jgoU9vuQldoqRcU1mv/ewC18ga+OTbjz/nTZzA7Zbj4+GuONmUfHLK SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Sep 2016 07:29:07.8624 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0701MB1728 Subject: Re: [dpdk-dev] [PATCH 1/6] ethdev: add Tx preparation 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, 08 Sep 2016 07:29:11 -0000 On Fri, Aug 26, 2016 at 06:22:53PM +0200, Tomasz Kulasek wrote: > Added API for `rte_eth_tx_prep` > > uint16_t rte_eth_tx_prep(uint8_t port_id, uint16_t queue_id, > struct rte_mbuf **tx_pkts, uint16_t nb_pkts) > > Added fields to the `struct rte_eth_desc_lim`: > > uint16_t nb_seg_max; > /**< Max number of segments per whole packet. */ > > uint16_t nb_mtu_seg_max; > /**< Max number of segments per one MTU */ > > Created `rte_pkt.h` header with common used functions: > > int rte_validate_tx_offload(struct rte_mbuf *m) > to validate general requirements for tx offload in packet such a > flag completness. In current implementation this function is called > optionaly when RTE_LIBRTE_ETHDEV_DEBUG is enabled. > > int rte_phdr_cksum_fix(struct rte_mbuf *m) > to fix pseudo header checksum for TSO and non-TSO tcp/udp packets > before hardware tx checksum offload. > - for non-TSO tcp/udp packets full pseudo-header checksum is > counted and set. > - for TSO the IP payload length is not included. > > Signed-off-by: Tomasz Kulasek > --- > lib/librte_ether/rte_ethdev.h | 74 +++++++++++++++++++++++ > lib/librte_mbuf/rte_mbuf.h | 8 +++ > lib/librte_net/Makefile | 2 +- > lib/librte_net/rte_pkt.h | 132 +++++++++++++++++++++++++++++++++++++++++ > 4 files changed, 215 insertions(+), 1 deletion(-) > create mode 100644 lib/librte_net/rte_pkt.h > > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h > index b0fe033..02569ca 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -182,6 +182,7 @@ extern "C" { > #include > #include > #include > +#include > #include "rte_ether.h" > #include "rte_eth_ctrl.h" > #include "rte_dev_info.h" > @@ -696,6 +697,8 @@ struct rte_eth_desc_lim { > uint16_t nb_max; /**< Max allowed number of descriptors. */ > uint16_t nb_min; /**< Min allowed number of descriptors. */ > uint16_t nb_align; /**< Number of descriptors should be aligned to. */ > + uint16_t nb_seg_max; /**< Max number of segments per whole packet. */ > + uint16_t nb_mtu_seg_max; /**< Max number of segments per one MTU */ > }; > > /** > @@ -1181,6 +1184,12 @@ typedef uint16_t (*eth_tx_burst_t)(void *txq, > uint16_t nb_pkts); > /**< @internal Send output packets on a transmit queue of an Ethernet device. */ > > +typedef uint16_t (*eth_tx_prep_t)(void *txq, > + struct rte_mbuf **tx_pkts, > + uint16_t nb_pkts); > +/**< @internal Prepare output packets on a transmit queue of an Ethernet > + device. */ > + > typedef int (*flow_ctrl_get_t)(struct rte_eth_dev *dev, > struct rte_eth_fc_conf *fc_conf); > /**< @internal Get current flow control parameter on an Ethernet device */ > @@ -1626,6 +1635,7 @@ enum rte_eth_dev_type { > struct rte_eth_dev { > eth_rx_burst_t rx_pkt_burst; /**< Pointer to PMD receive function. */ > eth_tx_burst_t tx_pkt_burst; /**< Pointer to PMD transmit function. */ > + eth_tx_prep_t tx_pkt_prep; /**< Pointer to PMD transmit prepare function. */ > struct rte_eth_dev_data *data; /**< Pointer to device data */ > const struct eth_driver *driver;/**< Driver for this device */ > const struct eth_dev_ops *dev_ops; /**< Functions exported by PMD */ > @@ -2833,6 +2843,70 @@ rte_eth_tx_burst(uint8_t port_id, uint16_t queue_id, > return (*dev->tx_pkt_burst)(dev->data->tx_queues[queue_id], tx_pkts, nb_pkts); > } > > +/** > + * Process a burst of output packets on a transmit queue of an Ethernet device. > + * > + * The rte_eth_tx_prep() function is invoked to prepare output packets to be > + * transmitted on the output queue *queue_id* of the Ethernet device designated > + * by its *port_id*. > + * The *nb_pkts* parameter is the number of packets to be prepared which are > + * supplied in the *tx_pkts* array of *rte_mbuf* structures, each of them > + * allocated from a pool created with rte_pktmbuf_pool_create(). > + * For each packet to send, the rte_eth_tx_prep() function performs > + * the following operations: > + * > + * - Check if packet meets devices requirements for tx offloads. > + * > + * - Check limitations about number of segments. > + * > + * - Check additional requirements when debug is enabled. > + * > + * - Update and/or reset required checksums when tx offload is set for packet. > + * > + * The rte_eth_tx_prep() function returns the number of packets ready to be > + * sent. A return value equal to *nb_pkts* means that all packets are valid and > + * ready to be sent. > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param queue_id > + * The index of the transmit queue through which output packets must be > + * sent. > + * The value must be in the range [0, nb_tx_queue - 1] previously supplied > + * to rte_eth_dev_configure(). > + * @param tx_pkts > + * The address of an array of *nb_pkts* pointers to *rte_mbuf* structures > + * which contain the output packets. > + * @param nb_pkts > + * The maximum number of packets to process. > + * @return > + * The number of packets correct and ready to be sent. The return value can be > + * less than the value of the *tx_pkts* parameter when some packet doesn't > + * meet devices requirements with rte_errno set appropriately. > + */ > +static inline uint16_t > +rte_eth_tx_prep(uint8_t port_id, uint16_t queue_id, struct rte_mbuf **tx_pkts, > + uint16_t nb_pkts) > +{ > + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; > + > + if (!dev->tx_pkt_prep) { > + rte_errno = -ENOTSUP; rte_errno update may not be necessary here. see below > + return 0; IMO, We should return "nb_pkts" here instead of 0(i.e, all the packets are valid in-case PMD does not have tx_prep function) and in-case of "0" the following check in the application also will fail for no reason if (nb_prep < nb_pkts) { printf("tx_prep failed\n"); } > + } > + > +#ifdef RTE_LIBRTE_ETHDEV_DEBUG > + if (queue_id >= dev->data->nb_tx_queues) { > + RTE_PMD_DEBUG_TRACE("Invalid TX queue_id=%d\n", queue_id); > + rte_errno = -EINVAL; > + return 0; > + } > +#endif > + > + return (*dev->tx_pkt_prep)(dev->data->tx_queues[queue_id], > + tx_pkts, nb_pkts); > +} > + IMO, We need to provide a compile time option for rte_eth_tx_prep as NOOP. Default option should be non NOOP but incase a _target_ want to override to NOOP it should be possible, the reasons is: - Low-end ARMv7,ARMv8 targets may not have PCIE-RC support and it may have only integrated NIC controller. On those targets, where integrated NIC controller does not use tx_prep service it can made it as NOOP to save cycles on following "rte_eth_tx_prep" and associated "if (unlikely(nb_prep < nb_rx))" checks in the application. /* Prepare burst of TX packets */ nb_prep = rte_eth_tx_prep(fs->rx_port, 0, pkts_burst, nb_rx); if (unlikely(nb_prep < nb_rx)) { int i; for (i = nb_prep; i < nb_rx; i++) rte_pktmbuf_free(pkts_burst[i]); } Jerin